diff --git a/appveyor.yml b/appveyor.yml index b2a9431742a..5ccf95ab3fe 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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')) @@ -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' diff --git a/scripts/Mark-RepoClean.ps1 b/scripts/Mark-RepoClean.ps1 index 819274cb575..2a193729830 100644 --- a/scripts/Mark-RepoClean.ps1 +++ b/scripts/Mark-RepoClean.ps1 @@ -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 { diff --git a/scripts/Update-DotnetVersion.ps1 b/scripts/Update-DotnetVersion.ps1 new file mode 100644 index 00000000000..e9eb9d2fd13 --- /dev/null +++ b/scripts/Update-DotnetVersion.ps1 @@ -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() +