Add script and instructions to install the latest version of WSL when the machine is in a bad MSIX state (#11500)
Blue committed
Apr 23, 2024 at 21:11 UTC
52bad1f2e24496a9e31397c66dd3eeec4188a825
2 files changed
+70
triage/config.yml
+20
@@ -90,6 +90,12 @@ rules:
90
name: user-visible-error
91
capture:
92
field3: error
93
+
94
+ - logline:
95
+ provider: Microsoft.Windows.Subsystem.Lxss
96
+ task: UserVisibleError
97
+ field3: Wsl/CallMsi/REGDB_E_CLASSNOTREG
98
+ set: msix-bad-install-state
99
100
- logline:
101
provider: Microsoft-Windows-Hyper-V-Chipset
@@ -271,3 +277,17 @@ actions:
277
condition: msix-install-error
278
debug_message: 'Found evidence of MSIX install error: $error, adding msix tag'
279
tag: 'msix'
280
+
281
+ - when:
282
+ condition: msix-bad-install-state
283
+ user_message: |
284
+ Your WSL installation appears to be in a bad state. Can you try running the following command to reinstall WSL (elevated powershell) and see if that solves the issue?
285
+
286
+ ```
287
+ Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/triage/install-latest-wsl.ps1" -OutFile install-latest-wsl.ps1
288
+ Set-ExecutionPolicy Bypass -Scope Process -Force
289
+ .\install-latest-wsl.ps1
290
+ ```
291
+
292
+
293
+ tag: 'msix'
triage/install-latest-wsl.ps1
new
+50
@@ -0,0 +1,50 @@
1
+#Requires -RunAsAdministrator
2
+
3
+# This script downloads and installs the latest version of the WSL MSI package
4
+
5
+$ErrorActionPreference = "Stop"
6
+Set-StrictMode -Version Latest
7
+
8
+$release = Invoke-WebRequest 'https://api.github.com/repos/microsoft/WSL/releases/latest' | ConvertFrom-Json
9
+$systeminfo = & systeminfo | findstr /C:"System Type"
10
+if ($systeminfo.contains('x64'))
11
+{
12
+ $target = '.x64.msi'
13
+} elseif ($systeminfo.contains('arm64'))
14
+{
15
+ $target = '.arm64.msi'
16
+} else
17
+{
18
+ throw 'Failed to determine system type ($systeminfo)'
19
+}
20
+
21
+[array]$assets = $release.assets | Where-Object { $_.name.ToLower().endswith('.x64.msi')}
22
+if ($assets.count -ne 1)
23
+{
24
+ throw 'Failed to find asset ($assets)'
25
+}
26
+
27
+$target = "$env:tmp\$($assets.name)"
28
+Write-Host "Downloading $($assets.name) to $target"
29
+
30
+$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
31
+$headers.Add('Accept','application/octet-stream')
32
+
33
+Invoke-WebRequest $assets.url -Out $target -Headers $headers
34
+
35
+$MSIArguments = @(
36
+ "/i"
37
+ $target
38
+ "/qn"
39
+ "/norestart"
40
+)
41
+
42
+$exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode
43
+if ($exitCode -Ne 0)
44
+{
45
+ throw "Failed to install package: $exitCode"
46
+}
47
+
48
+Write-Host 'Installation complete'
49
+
50
+Remove-Item $target -Force