From 7e145ef2da91f2ac49e9a4d4a988f309a02007ad Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 29 Oct 2020 17:35:34 -0700 Subject: [PATCH] Update script to use .NET RTM feeds (#13927) --- DotnetRuntimeMetadata.json | 6 +++--- nuget.config | 1 + tools/UpdateDotnetRuntime.ps1 | 36 +++++++++++++++++++++++++---------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/DotnetRuntimeMetadata.json b/DotnetRuntimeMetadata.json index 562987a835..84cdf2ce88 100644 --- a/DotnetRuntimeMetadata.json +++ b/DotnetRuntimeMetadata.json @@ -1,8 +1,8 @@ { "sdk": { - "channel": "release/5.0.1xx-rc2", - "packageVersionPattern": "5.0.0-rc.2", - "sdkImageVersion": "5.0.100-rc.2", + "channel": "release/5.0.1xx", + "packageVersionPattern": "5.0.0", + "sdkImageVersion": "5.0.100", "nextChannel": "net5/rc2" } } diff --git a/nuget.config b/nuget.config index cbb2494cec..a1713070c6 100644 --- a/nuget.config +++ b/nuget.config @@ -2,6 +2,7 @@ + diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index 93f3a1cbb4..5bbe5e5fae 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -19,7 +19,10 @@ param ( [string]$RuntimeSourceFeedKey, [Parameter()] - [switch]$InteractiveAuth + [switch]$InteractiveAuth, + + [Parameter()] + [switch]$UseRTMFeed ) <# @@ -94,7 +97,7 @@ function Update-PackageVersion { $versionPattern = (Get-Content "$PSScriptRoot/../DotnetRuntimeMetadata.json" | ConvertFrom-Json).sdk.packageVersionPattern - $source = if ($UseNuGetOrg) { 'nuget.org' } else { 'dotnet5' } + $source = if ($UseNuGetOrg) { 'nuget.org' } elseif ($UseRTMFeed) { 'dotnet5-rtm' } else { 'dotnet5' } $packages.GetEnumerator() | ForEach-Object { $pkgs = Find-Package -Name $_.Key -AllVersions -AllowPrereleaseVersions -Source $source @@ -102,7 +105,13 @@ function Update-PackageVersion { $version = $v.Version foreach ($p in $pkgs) { - if ($p.Version -like "$versionPattern*") { + if ($UseRTMFeed -and $p.Version -eq $versionPattern) { + if ([System.Management.Automation.SemanticVersion] ($version) -lt [System.Management.Automation.SemanticVersion] ($p.Version)) { + $v.NewVersion = $p.Version + break + } + } + elseif ($p.Version -like "$versionPattern*") { if ([System.Management.Automation.SemanticVersion] ($version) -lt [System.Management.Automation.SemanticVersion] ($p.Version)) { $v.NewVersion = $p.Version break @@ -201,19 +210,26 @@ if ($dotnetUpdate.ShouldUpdate) { Find-Dotnet - $addDotnet5Source = (-not (Get-PackageSource -Name 'dotnet5' -ErrorAction SilentlyContinue)) - $addDotnet5InternalSource = (-not (Get-PackageSource -Name 'dotnet5-internal' -ErrorAction SilentlyContinue)) + $feedname = if ($UseRTMFeed) { + 'dotnet5-rtm' + } elseif ($UseNuGetOrg) { + 'dotnet5' + } else { + 'dotnet-internal' + } + + $addDotnet5Source = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue)) if (!$UseNuGetOrg -and ($addDotnet5Source -or $addDotnet5InternalSource)) { $nugetFileSources = ([xml](Get-Content .\nuget.config -Raw)).Configuration.packagesources.add - if ($addDotnet5Source) { - $dotnet5Feed = $nugetFileSources | Where-Object { $_.Key -eq 'dotnet5' } | Select-Object -ExpandProperty Value - Register-PackageSource -Name 'dotnet5' -Location $dotnet5Feed -ProviderName NuGet - Write-Verbose -Message "Register new package source 'dotnet5'" -verbose + if ($addDotnet5Source -and $feedname -ne 'dotnet-internal') { + $dotnet5Feed = $nugetFileSources | Where-Object { $_.Key -eq $feedname } | Select-Object -ExpandProperty Value + Register-PackageSource -Name $feedname -Location $dotnet5Feed -ProviderName NuGet + Write-Verbose -Message "Register new package source $feedname" -verbose } - if ($addDotnet5InternalSource -and $InteractiveAuth) { + if ($addDotnet5Source -and $InteractiveAuth -and $feedname -eq 'dotnet-internal') { # This NuGet feed is for internal to Microsoft use only. $dotnet5InternalFeed = 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal/nuget/v3/index.json' $updatedNugetFile = (Get-Content .\nuget.config -Raw) -replace "", " `r`n "