Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Update-DotnetVersion script #10191

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ environment:
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Use latest version of current used .NET version. 6.0 could use the latest of 6.0. See .\Scripts\Update-DotnetVersion.ps1
GE_USE_LATEST_DOTNET: false

init:
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
Expand All @@ -35,6 +37,11 @@ build:
verbosity: minimal

install:
- ps: |
if($env:GE_USE_LATEST_DOTNET -eq $true)
{
.\scripts\Update-DotnetVersion.ps1
}
- ps: |
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1"
./dotnet-install.ps1 -JsonFile global.json -InstallDir 'C:\Program Files\dotnet'
Expand Down
4 changes: 4 additions & 0 deletions scripts/Mark-RepoClean.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

pushd $PSScriptRoot\..

# If the .NET SDK/runtime version was updated - make build clean
& git update-index --skip-worktree global.json
& git update-index --skip-worktree scripts/RepoLayout.props

# iterate through each submodule and mark each AssemblyInfo.cs in a submodule as clean
$submodules = git submodule --quiet foreach --recursive 'echo $name'
$submodules | ForEach-Object {
Expand Down
35 changes: 35 additions & 0 deletions scripts/Update-DotnetVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
param ( [string]$version = "6.0")

$encoding = [System.Text.UTF8Encoding]::new($false)

$path = Split-Path $MyInvocation.MyCommand.Path -Parent
$uri = "https://raw.githubusercontent.com/dotnet/core/main/release-notes/$version/releases.json"

# Get .NET version info
$releaseJson = Invoke-WebRequest -Uri $uri -ContentType "application/json" -Method Get -UseBasicParsing
$versionResult = $releaseJson.Content | Out-String | ConvertFrom-Json
Write-Output "Dotnet version info"
$versionResult | Format-List -Property channel-version, latest-release, latest-release-date, latest-runtime, latest-sdk, support-phase, eol-date

# Update global.json file
$globalJson = [System.IO.Path]::Combine($path, "..\global.json")
$globalJson = Resolve-Path $globalJson
$json = Get-Content $globalJson | ConvertFrom-Json
Write-Output "Updating SDK version from $($json.sdk.version) to $($versionResult.'latest-sdk')"
$json.sdk.version = $versionResult.'latest-sdk'
$json | ConvertTo-Json | Out-File -Encoding utf8 $globalJson

# Update RepoLayout.props file
$propsPath = [System.IO.Path]::Combine($path, "RepoLayout.props")
[xml]$props = Get-Content -Path $propsPath
$nd = $props.SelectSingleNode("/Project/PropertyGroup/RuntimeFrameworkVersion")
Write-Output "Updating Runtime version from $($nd.'#text') to $($versionResult.'latest-runtime')"
$nd.'#text' = $versionResult.'latest-runtime'
$settings = [System.Xml.XmlWriterSettings]@{
Encoding = $encoding
Indent = $true
}
$writer = [System.Xml.XmlWriter]::Create($propsPath, $settings)
$nd.OwnerDocument.Save($writer)
$writer.Dispose()