Skip to content

Commit 7d57cd0

Browse files
[windows] Fix .Net 8 SDK installation (#11555)
1 parent 650fb26 commit 7d57cd0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

images/windows/scripts/build/Install-DotnetSDK.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ $dotnetToolset = (Get-ToolsetContent).dotnet
9595
# Download installation script.
9696
$installScriptPath = Invoke-DownloadWithRetry -Url "https://dot.net/v1/dotnet-install.ps1"
9797

98+
# Visual Studio 2022 pre-creates sdk-manifests/8.0.100 folder, causing dotnet-install to skip manifests creation
99+
# https://github.com/actions/runner-images/issues/11402
100+
if (Test-IsWin22 -or Test-IsWin25) {
101+
$sdkManifestPath = "C:\Program Files\dotnet\sdk-manifests\8.0.100"
102+
if (Test-Path $sdkManifestPath) {
103+
Move-Item -Path $sdkManifestPath -Destination $env:TEMP_DIR -ErrorAction Stop
104+
}
105+
}
106+
98107
# Install and warm up dotnet
99108
foreach ($dotnetVersion in $dotnetToolset.versions) {
100109
$sdkVersionsToInstall = Get-SDKVersionsToInstall -DotnetVersion $dotnetVersion
@@ -106,6 +115,17 @@ foreach ($dotnetVersion in $dotnetToolset.versions) {
106115
}
107116
}
108117

118+
# Replace manifests inside sdk-manifests/8.0.100 folder with ones from Visual Studio
119+
# https://github.com/actions/runner-images/issues/11402
120+
if (Test-IsWin22 -or Test-IsWin25) {
121+
if (Test-Path "${env:TEMP_DIR}\8.0.100") {
122+
Get-ChildItem -Path "${env:TEMP_DIR}\8.0.100" | ForEach-Object {
123+
Remove-Item -Path "$sdkManifestPath\$($_.BaseName)" -Recurse -Force | Out-Null
124+
Move-Item -Path $_.FullName -Destination $sdkManifestPath -Force -ErrorAction Stop
125+
}
126+
}
127+
}
128+
109129
# Add dotnet to PATH
110130
Add-MachinePathItem "C:\Program Files\dotnet"
111131

0 commit comments

Comments
 (0)