From ccaa967c614d0d29434545d958862a9136b76462 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 4 Feb 2021 11:35:46 -0800 Subject: [PATCH 1/7] Update script to use .NET 6 build resources --- DotnetRuntimeMetadata.json | 11 ++++--- nuget.config | 2 +- tools/UpdateDotnetRuntime.ps1 | 57 ++++++++++++++++++----------------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/DotnetRuntimeMetadata.json b/DotnetRuntimeMetadata.json index 84cdf2ce88f..3bb3a075fcc 100644 --- a/DotnetRuntimeMetadata.json +++ b/DotnetRuntimeMetadata.json @@ -1,8 +1,11 @@ { "sdk": { - "channel": "release/5.0.1xx", - "packageVersionPattern": "5.0.0", - "sdkImageVersion": "5.0.100", - "nextChannel": "net5/rc2" + "channel": "release/6.0.1xx-preview1", + "packageVersionPattern": "6.0.0-preview.1", + "sdkImageVersion": "6.0.100", + "nextChannel": "net6/preview1" + }, + "internalfeed" : { + "url": "" } } diff --git a/nuget.config b/nuget.config index 760e780c8ec..a8ed27bf99e 100644 --- a/nuget.config +++ b/nuget.config @@ -2,7 +2,7 @@ - + diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index 5bbe5e5faed..a83b6da2404 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -22,7 +22,7 @@ param ( [switch]$InteractiveAuth, [Parameter()] - [switch]$UseRTMFeed + [switch]$UseInternalFeed ) <# @@ -68,6 +68,7 @@ function Update-PackageVersion { "Microsoft.Management.Infrastructure" "Microsoft.PowerShell.Native" "Microsoft.NETCore.Windows.ApiSets" + "Microsoft.PowerShell.MarkdownRender" ) $packages = [System.Collections.Generic.Dictionary[[string], [PkgVer[]] ]]::new() @@ -97,7 +98,13 @@ function Update-PackageVersion { $versionPattern = (Get-Content "$PSScriptRoot/../DotnetRuntimeMetadata.json" | ConvertFrom-Json).sdk.packageVersionPattern - $source = if ($UseNuGetOrg) { 'nuget.org' } elseif ($UseRTMFeed) { 'dotnet5-rtm' } else { 'dotnet5' } + $source = if ($UseNuGetOrg) { 'nuget.org' } elseif ($UseInternalFeed) { 'dotnet-internal' } else { 'dotnet' } + + # Always add nuget.org as some packages are only found there. + $source = if ($source -ne 'nuget.org') { + @($source, "nuget.org") + } + $packages.GetEnumerator() | ForEach-Object { $pkgs = Find-Package -Name $_.Key -AllVersions -AllowPrereleaseVersions -Source $source @@ -105,13 +112,8 @@ function Update-PackageVersion { $version = $v.Version foreach ($p in $pkgs) { - 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*") { + # some packages are directly updated on nuget.org so need to check that too. + if ($p.Version -like "$versionPattern*" -or $p.Source -eq 'nuget.org') { if ([System.Management.Automation.SemanticVersion] ($version) -lt [System.Management.Automation.SemanticVersion] ($p.Version)) { $v.NewVersion = $p.Version break @@ -152,17 +154,21 @@ 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 + if ($SDKVersionOverride) { return @{ ShouldUpdate = $true NewVersion = $SDKVersionOverride Message = $null + FeedUrl = $feedUrl } } try { - $dotnetMetadataPath = "$PSScriptRoot/../DotnetRuntimeMetadata.json" - $nextChannel = (Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json).sdk.nextChannel $latestSDKversion = [System.Management.Automation.SemanticVersion] (Invoke-RestMethod -Uri "http://aka.ms/dotnet/$nextChannel/Sdk/productVersion.txt" -ErrorAction Stop | ForEach-Object { $_.Trim() }) $currentVersion = [System.Management.Automation.SemanticVersion] (( Get-Content -Path "$PSScriptRoot/../global.json" -Raw | ConvertFrom-Json).sdk.version) @@ -184,6 +190,7 @@ function Get-DotnetUpdate { ShouldUpdate = $shouldUpdate NewVersion = $newVersion Message = $Message + FeedUrl = $feedUrl } } @@ -210,32 +217,26 @@ if ($dotnetUpdate.ShouldUpdate) { Find-Dotnet - $feedname = if ($UseRTMFeed) { - 'dotnet5-rtm' - } elseif ($UseNuGetOrg) { - 'dotnet5' - } else { - 'dotnet-internal' - } + $feedname = if ($UseNuGetOrg) { 'nuget.org' } elseif ($UseInternalFeed) { 'dotnet-internal' } else { 'dotnet' } - $addDotnet5Source = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue)) + $addDotnetSource = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue)) - if (!$UseNuGetOrg -and ($addDotnet5Source -or $addDotnet5InternalSource)) { + if (!$UseNuGetOrg -and ($addDotnetSource)) { $nugetFileSources = ([xml](Get-Content .\nuget.config -Raw)).Configuration.packagesources.add - 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 + if ($addDotnetSource -and $feedname -ne 'dotnet-internal') { + $dotnetFeed = $nugetFileSources | Where-Object { $_.Key -eq $feedname } | Select-Object -ExpandProperty Value + Register-PackageSource -Name $feedname -Location $dotnetFeed -ProviderName NuGet Write-Verbose -Message "Register new package source $feedname" -verbose } - if ($addDotnet5Source -and $InteractiveAuth -and $feedname -eq 'dotnet-internal') { + if ($addDotnetSource -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 " + $dotnetInternalFeed = $dotnetMetadataJson.internalfeed.url + $updatedNugetFile = (Get-Content .\nuget.config -Raw) -replace "", " `r`n " $updatedNugetFile | Out-File .\nuget.config -Force - Register-PackageSource -Name 'dotnet5-internal' -Location $dotnet5InternalFeed -ProviderName NuGet - Write-Verbose -Message "Register new package source 'dotnet5-internal'" -verbose + Register-PackageSource -Name 'dotnet-internal' -Location $dotnetInternalFeed -ProviderName NuGet + Write-Verbose -Message "Register new package source 'dotnet-internal'" -verbose } } From 382c4c894fde1559eff60e3359f94784035adac4 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 4 Feb 2021 16:31:15 -0800 Subject: [PATCH 2/7] Update tools/UpdateDotnetRuntime.ps1 Co-authored-by: Dongbo Wang --- tools/UpdateDotnetRuntime.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index a83b6da2404..8abcbc1a394 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -221,7 +221,7 @@ if ($dotnetUpdate.ShouldUpdate) { $addDotnetSource = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue)) - if (!$UseNuGetOrg -and ($addDotnetSource)) { + if (!$UseNuGetOrg -and $addDotnetSource) { $nugetFileSources = ([xml](Get-Content .\nuget.config -Raw)).Configuration.packagesources.add if ($addDotnetSource -and $feedname -ne 'dotnet-internal') { From ee6cee965ec29be3192007734ab688e7ebf6202f Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 4 Feb 2021 16:31:36 -0800 Subject: [PATCH 3/7] Update tools/UpdateDotnetRuntime.ps1 Co-authored-by: Dongbo Wang --- tools/UpdateDotnetRuntime.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index 8abcbc1a394..d9218138b0c 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -222,7 +222,7 @@ if ($dotnetUpdate.ShouldUpdate) { $addDotnetSource = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue)) if (!$UseNuGetOrg -and $addDotnetSource) { - $nugetFileSources = ([xml](Get-Content .\nuget.config -Raw)).Configuration.packagesources.add + $nugetFileSources = ([xml](Get-Content "$PSScriptRoot/../nuget.config" -Raw)).Configuration.packagesources.add if ($addDotnetSource -and $feedname -ne 'dotnet-internal') { $dotnetFeed = $nugetFileSources | Where-Object { $_.Key -eq $feedname } | Select-Object -ExpandProperty Value From c9acca4326bee6db52a3e96d28eab04e94a50d17 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 4 Feb 2021 16:31:50 -0800 Subject: [PATCH 4/7] Update tools/UpdateDotnetRuntime.ps1 Co-authored-by: Dongbo Wang --- tools/UpdateDotnetRuntime.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index d9218138b0c..1adff395d1a 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -224,7 +224,7 @@ if ($dotnetUpdate.ShouldUpdate) { if (!$UseNuGetOrg -and $addDotnetSource) { $nugetFileSources = ([xml](Get-Content "$PSScriptRoot/../nuget.config" -Raw)).Configuration.packagesources.add - if ($addDotnetSource -and $feedname -ne 'dotnet-internal') { + if ($feedname -ne 'dotnet-internal') { $dotnetFeed = $nugetFileSources | Where-Object { $_.Key -eq $feedname } | Select-Object -ExpandProperty Value Register-PackageSource -Name $feedname -Location $dotnetFeed -ProviderName NuGet Write-Verbose -Message "Register new package source $feedname" -verbose From 61fc986551deb961cd4e86e80dbb2d137df99c0f Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 4 Feb 2021 16:32:04 -0800 Subject: [PATCH 5/7] Update tools/UpdateDotnetRuntime.ps1 Co-authored-by: Dongbo Wang --- tools/UpdateDotnetRuntime.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index 1adff395d1a..851b74bd98d 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -230,7 +230,7 @@ if ($dotnetUpdate.ShouldUpdate) { Write-Verbose -Message "Register new package source $feedname" -verbose } - if ($addDotnetSource -and $feedname -eq 'dotnet-internal') { + if ($feedname -eq 'dotnet-internal') { # This NuGet feed is for internal to Microsoft use only. $dotnetInternalFeed = $dotnetMetadataJson.internalfeed.url $updatedNugetFile = (Get-Content .\nuget.config -Raw) -replace "", " `r`n " From c5afcaf0267b730d7afbac058208133ca57af8c5 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 4 Feb 2021 16:32:29 -0800 Subject: [PATCH 6/7] Update tools/UpdateDotnetRuntime.ps1 Co-authored-by: Dongbo Wang --- tools/UpdateDotnetRuntime.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index 851b74bd98d..e2cb07a1011 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -233,7 +233,7 @@ if ($dotnetUpdate.ShouldUpdate) { if ($feedname -eq 'dotnet-internal') { # This NuGet feed is for internal to Microsoft use only. $dotnetInternalFeed = $dotnetMetadataJson.internalfeed.url - $updatedNugetFile = (Get-Content .\nuget.config -Raw) -replace "", " `r`n " + $updatedNugetFile = (Get-Content "$PSScriptRoot/../nuget.config" -Raw) -replace "", " `r`n " $updatedNugetFile | Out-File .\nuget.config -Force Register-PackageSource -Name 'dotnet-internal' -Location $dotnetInternalFeed -ProviderName NuGet Write-Verbose -Message "Register new package source 'dotnet-internal'" -verbose From d5b3cd15af136e90c8c31821f3966737e060779e Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 4 Feb 2021 17:05:22 -0800 Subject: [PATCH 7/7] Address feedback --- DotnetRuntimeMetadata.json | 2 +- tools/UpdateDotnetRuntime.ps1 | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DotnetRuntimeMetadata.json b/DotnetRuntimeMetadata.json index 3bb3a075fcc..418291f1a39 100644 --- a/DotnetRuntimeMetadata.json +++ b/DotnetRuntimeMetadata.json @@ -6,6 +6,6 @@ "nextChannel": "net6/preview1" }, "internalfeed" : { - "url": "" + "url": null } } diff --git a/tools/UpdateDotnetRuntime.ps1 b/tools/UpdateDotnetRuntime.ps1 index e2cb07a1011..4bc9472bd3c 100644 --- a/tools/UpdateDotnetRuntime.ps1 +++ b/tools/UpdateDotnetRuntime.ps1 @@ -222,7 +222,8 @@ if ($dotnetUpdate.ShouldUpdate) { $addDotnetSource = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue)) if (!$UseNuGetOrg -and $addDotnetSource) { - $nugetFileSources = ([xml](Get-Content "$PSScriptRoot/../nuget.config" -Raw)).Configuration.packagesources.add + $nugetFileContent = Get-Content "$PSScriptRoot/../nuget.config" -Raw + $nugetFileSources = ([xml]($nugetFileContent)).Configuration.packagesources.add if ($feedname -ne 'dotnet-internal') { $dotnetFeed = $nugetFileSources | Where-Object { $_.Key -eq $feedname } | Select-Object -ExpandProperty Value @@ -233,8 +234,8 @@ if ($dotnetUpdate.ShouldUpdate) { if ($feedname -eq 'dotnet-internal') { # This NuGet feed is for internal to Microsoft use only. $dotnetInternalFeed = $dotnetMetadataJson.internalfeed.url - $updatedNugetFile = (Get-Content "$PSScriptRoot/../nuget.config" -Raw) -replace "", " `r`n " - $updatedNugetFile | Out-File .\nuget.config -Force + $updatedNugetFile = $nugetFileContent -replace "", " `r`n " + $updatedNugetFile | Out-File "$PSScriptRoot/../nuget.config" -Force Register-PackageSource -Name 'dotnet-internal' -Location $dotnetInternalFeed -ProviderName NuGet Write-Verbose -Message "Register new package source 'dotnet-internal'" -verbose }