Skip to content

improve Get .NET versions #5

improve Get .NET versions

improve Get .NET versions #5

Workflow file for this run

name: MSBuild
on:
push:
branches:
- dev/pipeline
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
configuration: [Release]
platform: [x64]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get .NET versions
run: |
$csprojFiles = Get-ChildItem -Path './*.csproj', '**/*.csproj'
$versions = @()
foreach ($file in $csprojFiles) {
[xml]$csproj = Get-Content -Path $file.FullName
$framework = $csproj.Project.PropertyGroup.TargetFramework
if ($framework -match 'net(\d+\.\d+)') {
$version = $matches[1]
Write-Host "$($file.FullName): $version"
$versions += $version
}
}
$uniqueversions = $versions | Sort-Object -Unique
$uniqueversions -join ',' | Out-File -FilePath versions.txt
echo "$(Get-Content versions.txt)" >> $GITHUB_ENV
- name: Setup .NET
run: |
$versions = $env:versions -split ','
foreach ($version in $versions) {
actions/setup-dotnet@v1 --dotnet-version $version
}
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
- name: Restore NuGet packages
run: msbuild -t:Restore -p:Configuration=${{ matrix.configuration }}
- name: Build solution
run: msbuild -p:Configuration=${{ matrix.configuration }} -p:Platform=${{ matrix.platform }}
- name: Create MSIX package
run: msbuild -t:Pack -p:Configuration=${{ matrix.configuration }} -p:Platform=${{ matrix.platform }} -p:GenerateAppxPackageOnBuild=true
- name: Upload MSIX package
uses: actions/upload-artifact@v2
with:
name: msix-package
path: '**/*.msix'