Skip to content

Commit fdc9a91

Browse files
Update script to use .NET 6 build resources (#14705)
1 parent 8d7d5e7 commit fdc9a91

File tree

3 files changed

+40
-35
lines changed

3 files changed

+40
-35
lines changed

DotnetRuntimeMetadata.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"sdk": {
3-
"channel": "release/5.0.1xx",
4-
"packageVersionPattern": "5.0.0",
5-
"sdkImageVersion": "5.0.100",
6-
"nextChannel": "net5/rc2"
3+
"channel": "release/6.0.1xx-preview1",
4+
"packageVersionPattern": "6.0.0-preview.1",
5+
"sdkImageVersion": "6.0.100",
6+
"nextChannel": "net6/preview1"
7+
},
8+
"internalfeed" : {
9+
"url": null
710
}
811
}

nuget.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration>
33
<packageSources>
44
<clear />
5-
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
5+
<add key="dotnet" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v2" />
66
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
77
</packageSources>
88
<disabledPackageSources>

tools/UpdateDotnetRuntime.ps1

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ param (
2222
[switch]$InteractiveAuth,
2323

2424
[Parameter()]
25-
[switch]$UseRTMFeed
25+
[switch]$UseInternalFeed
2626
)
2727

2828
<#
@@ -68,6 +68,7 @@ function Update-PackageVersion {
6868
"Microsoft.Management.Infrastructure"
6969
"Microsoft.PowerShell.Native"
7070
"Microsoft.NETCore.Windows.ApiSets"
71+
"Microsoft.PowerShell.MarkdownRender"
7172
)
7273

7374
$packages = [System.Collections.Generic.Dictionary[[string], [PkgVer[]] ]]::new()
@@ -97,21 +98,22 @@ function Update-PackageVersion {
9798

9899
$versionPattern = (Get-Content "$PSScriptRoot/../DotnetRuntimeMetadata.json" | ConvertFrom-Json).sdk.packageVersionPattern
99100

100-
$source = if ($UseNuGetOrg) { 'nuget.org' } elseif ($UseRTMFeed) { 'dotnet5-rtm' } else { 'dotnet5' }
101+
$source = if ($UseNuGetOrg) { 'nuget.org' } elseif ($UseInternalFeed) { 'dotnet-internal' } else { 'dotnet' }
102+
103+
# Always add nuget.org as some packages are only found there.
104+
$source = if ($source -ne 'nuget.org') {
105+
@($source, "nuget.org")
106+
}
107+
101108
$packages.GetEnumerator() | ForEach-Object {
102109
$pkgs = Find-Package -Name $_.Key -AllVersions -AllowPrereleaseVersions -Source $source
103110

104111
foreach ($v in $_.Value) {
105112
$version = $v.Version
106113

107114
foreach ($p in $pkgs) {
108-
if ($UseRTMFeed -and $p.Version -eq $versionPattern) {
109-
if ([System.Management.Automation.SemanticVersion] ($version) -lt [System.Management.Automation.SemanticVersion] ($p.Version)) {
110-
$v.NewVersion = $p.Version
111-
break
112-
}
113-
}
114-
elseif ($p.Version -like "$versionPattern*") {
115+
# some packages are directly updated on nuget.org so need to check that too.
116+
if ($p.Version -like "$versionPattern*" -or $p.Source -eq 'nuget.org') {
115117
if ([System.Management.Automation.SemanticVersion] ($version) -lt [System.Management.Automation.SemanticVersion] ($p.Version)) {
116118
$v.NewVersion = $p.Version
117119
break
@@ -152,17 +154,21 @@ function Update-CsprojFile([string] $path, $values) {
152154
}
153155

154156
function Get-DotnetUpdate {
157+
$dotnetMetadataPath = "$PSScriptRoot/../DotnetRuntimeMetadata.json"
158+
$metataJson = (Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json)
159+
$nextChannel = $metataJson.sdk.nextChannel
160+
$feedUrl = $metataJson.internalfeed.url
161+
155162
if ($SDKVersionOverride) {
156163
return @{
157164
ShouldUpdate = $true
158165
NewVersion = $SDKVersionOverride
159166
Message = $null
167+
FeedUrl = $feedUrl
160168
}
161169
}
162170

163171
try {
164-
$dotnetMetadataPath = "$PSScriptRoot/../DotnetRuntimeMetadata.json"
165-
$nextChannel = (Get-Content $dotnetMetadataPath -Raw | ConvertFrom-Json).sdk.nextChannel
166172
$latestSDKversion = [System.Management.Automation.SemanticVersion] (Invoke-RestMethod -Uri "http://aka.ms/dotnet/$nextChannel/Sdk/productVersion.txt" -ErrorAction Stop | ForEach-Object { $_.Trim() })
167173
$currentVersion = [System.Management.Automation.SemanticVersion] (( Get-Content -Path "$PSScriptRoot/../global.json" -Raw | ConvertFrom-Json).sdk.version)
168174

@@ -184,6 +190,7 @@ function Get-DotnetUpdate {
184190
ShouldUpdate = $shouldUpdate
185191
NewVersion = $newVersion
186192
Message = $Message
193+
FeedUrl = $feedUrl
187194
}
188195
}
189196

@@ -210,32 +217,27 @@ if ($dotnetUpdate.ShouldUpdate) {
210217

211218
Find-Dotnet
212219

213-
$feedname = if ($UseRTMFeed) {
214-
'dotnet5-rtm'
215-
} elseif ($UseNuGetOrg) {
216-
'dotnet5'
217-
} else {
218-
'dotnet-internal'
219-
}
220+
$feedname = if ($UseNuGetOrg) { 'nuget.org' } elseif ($UseInternalFeed) { 'dotnet-internal' } else { 'dotnet' }
220221

221-
$addDotnet5Source = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue))
222+
$addDotnetSource = (-not (Get-PackageSource -Name $feedname -ErrorAction SilentlyContinue))
222223

223-
if (!$UseNuGetOrg -and ($addDotnet5Source -or $addDotnet5InternalSource)) {
224-
$nugetFileSources = ([xml](Get-Content .\nuget.config -Raw)).Configuration.packagesources.add
224+
if (!$UseNuGetOrg -and $addDotnetSource) {
225+
$nugetFileContent = Get-Content "$PSScriptRoot/../nuget.config" -Raw
226+
$nugetFileSources = ([xml]($nugetFileContent)).Configuration.packagesources.add
225227

226-
if ($addDotnet5Source -and $feedname -ne 'dotnet-internal') {
227-
$dotnet5Feed = $nugetFileSources | Where-Object { $_.Key -eq $feedname } | Select-Object -ExpandProperty Value
228-
Register-PackageSource -Name $feedname -Location $dotnet5Feed -ProviderName NuGet
228+
if ($feedname -ne 'dotnet-internal') {
229+
$dotnetFeed = $nugetFileSources | Where-Object { $_.Key -eq $feedname } | Select-Object -ExpandProperty Value
230+
Register-PackageSource -Name $feedname -Location $dotnetFeed -ProviderName NuGet
229231
Write-Verbose -Message "Register new package source $feedname" -verbose
230232
}
231233

232-
if ($addDotnet5Source -and $InteractiveAuth -and $feedname -eq 'dotnet-internal') {
234+
if ($feedname -eq 'dotnet-internal') {
233235
# This NuGet feed is for internal to Microsoft use only.
234-
$dotnet5InternalFeed = 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal/nuget/v3/index.json'
235-
$updatedNugetFile = (Get-Content .\nuget.config -Raw) -replace "</packageSources>", " <add key=`"dotnet5-internal`" value=`"$dotnet5InternalFeed`" />`r`n </packageSources>"
236-
$updatedNugetFile | Out-File .\nuget.config -Force
237-
Register-PackageSource -Name 'dotnet5-internal' -Location $dotnet5InternalFeed -ProviderName NuGet
238-
Write-Verbose -Message "Register new package source 'dotnet5-internal'" -verbose
236+
$dotnetInternalFeed = $dotnetMetadataJson.internalfeed.url
237+
$updatedNugetFile = $nugetFileContent -replace "</packageSources>", " <add key=`"dotnet-internal`" value=`"$dotnetInternalFeed`" />`r`n </packageSources>"
238+
$updatedNugetFile | Out-File "$PSScriptRoot/../nuget.config" -Force
239+
Register-PackageSource -Name 'dotnet-internal' -Location $dotnetInternalFeed -ProviderName NuGet
240+
Write-Verbose -Message "Register new package source 'dotnet-internal'" -verbose
239241
}
240242
}
241243

0 commit comments

Comments
 (0)