Update script to use .NET RTM feeds (#13927)

This commit is contained in:
Aditya Patwardhan 2020-10-29 17:35:34 -07:00 committed by GitHub
parent c4f6bfe771
commit 7e145ef2da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 13 deletions

View file

@ -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"
}
}

View file

@ -2,6 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="dotnet5-rtm" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/5.0.100-rtm.20526.5/nuget/v3/index.json" />
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />

View file

@ -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 "</packageSources>", " <add key=`"dotnet5-internal`" value=`"$dotnet5InternalFeed`" />`r`n </packageSources>"