Skip to content

Commit

Permalink
Making .NET version check less sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeCyclone committed Oct 1, 2024
1 parent bded7a8 commit 6846fea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x' # SDK Version to use.
#dotnet-version: '8.0.x' # SDK Version to use.
global-json-file: 'global.json'
source-url: https://nuget.pkg.github.com/microsoft/powerbi-powershell/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
uses: actions/setup-dotnet@v3
with:
# Semantic version range syntax or exact version of a dotnet version
dotnet-version: '8.x'
#dotnet-version: '8.x'
global-json-file: 'global.json'

- uses: actions/cache@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"sdk": {
"version": "8.0.303"
"version": "8.0.402",
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "4.1.0",
Expand Down
23 changes: 16 additions & 7 deletions scripts/GetNetstandardAssembly.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,32 @@ param
[string] $SdkInstallDir = ($IsLinux) ? '/usr/share/dotnet/sdk' : 'C:\Program Files\dotnet\sdk\',

# The installed .NET SDK must have the same major and minor number and a lower build\patch number.
[ValidateNotNullOrEmpty()]
[string] $MajorMinorSDKVersionCheck = '8.0.202'
[string] $MajorMinorSDKVersionCheck = '8.0.900'
)

# .NET CORE 2.0 Downloads - https://www.microsoft.com/net/download/dotnet-core/2.0
# .NET CORE 2.1 Downloads - https://www.microsoft.com/net/download/dotnet-core/2.1

$versionCheck = [version]$MajorMinorSDKVersionCheck
$sdkVersions = Get-ChildItem -Path $SdkInstallDir -Directory | Where-Object Name -Match '\d+\.\d+\.\d+$' | ForEach-Object {
$version = [version]$_.BaseName
$_ | Add-Member -Name SDKVersion -MemberType NoteProperty -Value $version
$_
}
$sdkDir = $sdkVersions | Where-Object { $_.SDKVersion.Major -eq $versionCheck.Major -and $_.SDKVersion.Minor -eq $versionCheck.Minor -and $_.SDKVersion.Build -lt $versionCheck.Build } | Sort-Object SDKVersion -Descending | Select-Object -First 1

if ($MajorMinorSDKVersionCheck) {
Write-Verbose "Checking for SDK version less than: $MajorMinorSDKVersionCheck"
$versionCheck = [version]$MajorMinorSDKVersionCheck
$sdkDir = $sdkVersions | Where-Object { $_.SDKVersion.Major -eq $versionCheck.Major -and $_.SDKVersion.Minor -eq $versionCheck.Minor -and $_.SDKVersion.Build -lt $versionCheck.Build } | Sort-Object SDKVersion -Descending | Select-Object -First 1

if(!$sdkDir) {
throw "Unable to find SDK version (less than $MajorMinorSDKVersionCheck) under: $SdkInstallDir`nVersions available: $(($sdkVersions | % { $_.BaseName }) -join ', ' )"
}
}
else {
Write-Verbose "Checking for latest SDK version"
$sdkDir = $sdkVersions | Sort-Object SDKVersion -Descending | Select-Object -First 1
}

if(!$sdkDir) {
throw "Unable to find SDK version (less than $MajorMinorSDKVersionCheck) under: $SdkInstallDir`nVersions available: $(($sdkVersions | % { $_.BaseName }) -join ', ' )"
throw "Unable to find SDK version under: $SdkInstallDir"
}

Write-Verbose "Using SDK: $($sdkDir.FullName)"
Expand Down

0 comments on commit 6846fea

Please sign in to comment.