Update the script to use quality parameter for dotnet-install (#15731)

This commit is contained in:
Aditya Patwardhan 2021-07-07 10:10:40 -07:00 committed by GitHub
parent acb4c4acff
commit 996d830de2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 20 deletions

View file

@ -1,9 +1,11 @@
{
"sdk": {
"channel": "release/6.0.1xx-preview4",
"channel": "6.0.1xx-preview4",
"quality": "signed",
"qualityFallback": "daily",
"packageVersionPattern": "6.0.0-preview.4",
"sdkImageVersion": "6.0.100",
"nextChannel": "6.0.1xx-preview5/daily"
"nextChannel": "6.0.1xx-preview6"
},
"internalfeed" : {
"url": null

View file

@ -13,7 +13,9 @@ Set-StrictMode -Version 3.0
$script:TestModulePathSeparator = [System.IO.Path]::PathSeparator
$script:Options = $null
$dotnetCLIChannel = $(Get-Content $PSScriptRoot/DotnetRuntimeMetadata.json | ConvertFrom-Json).Sdk.Channel
$dotnetMetadata = Get-Content $PSScriptRoot/DotnetRuntimeMetadata.json | ConvertFrom-Json
$dotnetCLIChannel = $dotnetMetadata.Sdk.Channel
$dotnetCLIQuality = $dotnetMetadata.Sdk.Quality
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
# Track if tags have been sync'ed
@ -1699,6 +1701,7 @@ function Install-Dotnet {
param(
[string]$Channel = $dotnetCLIChannel,
[string]$Version = $dotnetCLIRequiredVersion,
[string]$Quality = $dotnetCLIQuality,
[switch]$NoSudo,
[string]$InstallDir,
[string]$AzureFeed,
@ -1742,7 +1745,12 @@ function Install-Dotnet {
throw "./$installScript was 0 length"
}
$bashArgs = @("./$installScript", '-c', $Channel, '-v', $Version)
if ($Version) {
$bashArgs = @("./$installScript", '-v', $Version, '-q', $Quality)
}
elseif ($Channel) {
$bashArgs = @("./$installScript", '-c', $Channel, '-q', $Quality)
}
if ($InstallDir) {
$bashArgs += @('-i', $InstallDir)
@ -1761,7 +1769,7 @@ function Install-Dotnet {
if (-not $environment.IsCoreCLR) {
$installArgs = @{
Channel = $Channel
Version = $Version
Quality = $Quality
}
if ($InstallDir) {
@ -1782,7 +1790,13 @@ function Install-Dotnet {
$fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe"
$fullDotnetInstallPath = Join-Path -Path $PWD.Path -ChildPath $installScript
Start-NativeExecution {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Version', $Version)
if ($Version) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Version', $Version, '-Quality', $Quality)
}
elseif ($Channel) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Quality', $Quality)
}
if ($InstallDir) {
$psArgs += @('-InstallDir', $InstallDir)

View file

@ -76,6 +76,7 @@ function Update-PackageVersion {
$paths = @(
"$PSScriptRoot/packaging/projects/reference/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj"
"$PSScriptRoot/packaging/projects/reference/System.Management.Automation/System.Management.Automation.csproj"
"$PSScriptRoot/packaging/projects/reference/Microsoft.PowerShell.ConsoleHost/Microsoft.PowerShell.ConsoleHost.csproj"
"$PSScriptRoot/../src/"
"$PSScriptRoot/../test/tools/"
)
@ -154,10 +155,13 @@ function Update-CsprojFile([string] $path, $values) {
}
function Get-DotnetUpdate {
$dotnetMetadataPath = "$PSScriptRoot/../DotnetRuntimeMetadata.json"
$metataJson = (Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json)
$nextChannel = $metataJson.sdk.nextChannel
$feedUrl = $metataJson.internalfeed.url
param (
$channel,
$quality,
$qualityFallback,
$feedUrl,
$sdkImageVersion
)
if ($SDKVersionOverride) {
return @{
@ -169,7 +173,24 @@ function Get-DotnetUpdate {
}
try {
$latestSDKversion = [System.Management.Automation.SemanticVersion] (Invoke-RestMethod -Uri "http://aka.ms/dotnet/$nextChannel/sdk-productVersion.txt" -ErrorAction Stop | ForEach-Object { $_.Trim() })
$latestSDKVersionString = Invoke-RestMethod -Uri "http://aka.ms/dotnet/$channel/$quality/sdk-productVersion.txt" -ErrorAction Stop | ForEach-Object { $_.Trim() }
$selectedQuality = $quality
if (-not $latestSDKVersionString.StartsWith($sdkImageVersion))
{
# we did not get a version number so fall back to daily
$latestSDKVersionString = Invoke-RestMethod -Uri "http://aka.ms/dotnet/$channel/$qualityFallback/sdk-productVersion.txt" -ErrorAction Stop | ForEach-Object { $_.Trim() }
$selectedQuality = $qualityFallback
if (-not $latestSDKVersionString.StartsWith($sdkImageVersion))
{
throw "No build found!"
}
}
$latestSDKversion = [System.Management.Automation.SemanticVersion] $latestSDKVersionString
$currentVersion = [System.Management.Automation.SemanticVersion] (( Get-Content -Path "$PSScriptRoot/../global.json" -Raw | ConvertFrom-Json).sdk.version)
if ($latestSDKversion -gt $currentVersion) {
@ -191,6 +212,7 @@ function Get-DotnetUpdate {
NewVersion = $newVersion
Message = $Message
FeedUrl = $feedUrl
Quality = $selectedQuality
}
}
@ -203,16 +225,19 @@ function Update-DevContainer {
$devContainerDocker | Out-File -FilePath $dockerFilePath -Force
}
$dotnetUpdate = Get-DotnetUpdate
$dotnetMetadataPath = "$PSScriptRoot/../DotnetRuntimeMetadata.json"
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json
$channel = $dotnetMetadataJson.sdk.channel
$nextChannel = $dotnetMetadataJson.sdk.nextChannel
$quality = $dotnetMetadataJson.sdk.quality
$qualityFallback = $dotnetMetadataJson.sdk.qualityFallback
$sdkImageVersion = $dotnetMetadataJson.sdk.sdkImageVersion
$internalfeed = $dotnetMetadataJson.internalfeed.url
$dotnetUpdate = Get-DotnetUpdate -channel $nextChannel -quality $quality -feedUrl $internalfeed -qualityFallback $qualityFallback -sdkImageVersion $sdkImageVersion
if ($dotnetUpdate.ShouldUpdate) {
$dotnetMetadataPath = "$PSScriptRoot/../DotnetRuntimeMetadata.json"
$dotnetMetadataJson = Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json
# Channel is like: $Channel = "5.0.1xx-preview2"
$Channel = $dotnetMetadataJson.sdk.channel
Import-Module "$PSScriptRoot/../build.psm1" -Force
Find-Dotnet
@ -243,13 +268,14 @@ if ($dotnetUpdate.ShouldUpdate) {
## Install latest version from the channel
$sdkQuality = $dotnetUpdate.Quality
$sdkVersion = if ($SDKVersionOverride) { $SDKVersionOverride } else { $dotnetUpdate.NewVersion }
if (-not $RuntimeSourceFeed) {
Install-Dotnet -Channel "$Channel" -Version $sdkVersion
Install-Dotnet -Version $sdkVersion -Quality $sdkQuality -Channel $null
}
else {
Install-Dotnet -Channel "$Channel" -Version $sdkVersion -AzureFeed $RuntimeSourceFeed -FeedCredential $RuntimeSourceFeedKey
Install-Dotnet -Version $sdkVersion -Quality $sdkQuality -AzureFeed $RuntimeSourceFeed -FeedCredential $RuntimeSourceFeedKey -Channel $null
}
Write-Verbose -Message "Installing .NET SDK completed." -Verbose