From 7d57cd009f879836e38850faa0b50e3eb93fb940 Mon Sep 17 00:00:00 2001 From: Shamil Mubarakshin <127750046+shamil-mubarakshin@users.noreply.github.com> Date: Fri, 7 Feb 2025 11:09:06 +0100 Subject: [PATCH] [windows] Fix .Net 8 SDK installation (#11555) --- .../scripts/build/Install-DotnetSDK.ps1 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/images/windows/scripts/build/Install-DotnetSDK.ps1 b/images/windows/scripts/build/Install-DotnetSDK.ps1 index 493720f3..68c2ff6c 100644 --- a/images/windows/scripts/build/Install-DotnetSDK.ps1 +++ b/images/windows/scripts/build/Install-DotnetSDK.ps1 @@ -95,6 +95,15 @@ $dotnetToolset = (Get-ToolsetContent).dotnet # Download installation script. $installScriptPath = Invoke-DownloadWithRetry -Url "https://dot.net/v1/dotnet-install.ps1" +# Visual Studio 2022 pre-creates sdk-manifests/8.0.100 folder, causing dotnet-install to skip manifests creation +# https://github.com/actions/runner-images/issues/11402 +if (Test-IsWin22 -or Test-IsWin25) { + $sdkManifestPath = "C:\Program Files\dotnet\sdk-manifests\8.0.100" + if (Test-Path $sdkManifestPath) { + Move-Item -Path $sdkManifestPath -Destination $env:TEMP_DIR -ErrorAction Stop + } +} + # Install and warm up dotnet foreach ($dotnetVersion in $dotnetToolset.versions) { $sdkVersionsToInstall = Get-SDKVersionsToInstall -DotnetVersion $dotnetVersion @@ -106,6 +115,17 @@ foreach ($dotnetVersion in $dotnetToolset.versions) { } } +# Replace manifests inside sdk-manifests/8.0.100 folder with ones from Visual Studio +# https://github.com/actions/runner-images/issues/11402 +if (Test-IsWin22 -or Test-IsWin25) { + if (Test-Path "${env:TEMP_DIR}\8.0.100") { + Get-ChildItem -Path "${env:TEMP_DIR}\8.0.100" | ForEach-Object { + Remove-Item -Path "$sdkManifestPath\$($_.BaseName)" -Recurse -Force | Out-Null + Move-Item -Path $_.FullName -Destination $sdkManifestPath -Force -ErrorAction Stop + } + } +} + # Add dotnet to PATH Add-MachinePathItem "C:\Program Files\dotnet"