Skip to content

Commit

Permalink
Update verify-dotnet.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanZosimov committed Apr 19, 2023
1 parent e8ac21d commit 50b46b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0', '6.0', '7.0']
dotnet-version: ['2.1', '2.2', '3.0', '3.1', '5.0', '6.0', '7.0', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
11 changes: 10 additions & 1 deletion __tests__/verify-dotnet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,26 @@ $targetFrameworkVersionMap = @{
"5.0" = "net5.0";
"6.0" = "net6.0";
"7.0" = "net7.0";
"8.0" = "net8.0";
}

foreach ($version in $Versions)
{
# Creating temporary global.json file inside e2e-test-csproj dir and setting exact version of .NET inside allows to override default behavior of .NET and run build and tests on that exact version.
Write-Host "Creating temporary global.json file for $version .NET version."
& $dotnet new globaljson --sdk-version $version --force
if (!(Test-Path "./global.json"))
{
throw "An error occured while creating the global.json file. Exit code: $LASTEXITCODE"
}
Write-Host "The global.json file for the version $version is created. Currently used .NET version is: $(& $dotnet --version)."

# Environment variable TEST_TARGET_FRAMEWORK is used inside the test.csproj file to target required framework version
$version -match "^(?<key>\d+\.\d+)"
$version -match "^(?<key>\d+\.\d+)" | Out-Null
if (!($targetFrameworkVersionMap.ContainsKey($Matches.key)))
{
throw "The map with the framework targets doesn't contain a target name for the version $version."
}
Write-Host "Setting the TEST_TARGET_FRAMEWORK environment variable to $($targetFrameworkVersionMap[$Matches.key])"
[Environment]::SetEnvironmentVariable('TEST_TARGET_FRAMEWORK', $($targetFrameworkVersionMap[$Matches.key]))

Expand Down

0 comments on commit 50b46b3

Please sign in to comment.