diff --git a/triage/config.yml b/triage/config.yml index 48ac38ce..fe564c1c 100644 --- a/triage/config.yml +++ b/triage/config.yml @@ -90,6 +90,12 @@ rules: name: user-visible-error capture: field3: error + + - logline: + provider: Microsoft.Windows.Subsystem.Lxss + task: UserVisibleError + field3: Wsl/CallMsi/REGDB_E_CLASSNOTREG + set: msix-bad-install-state - logline: provider: Microsoft-Windows-Hyper-V-Chipset @@ -271,3 +277,17 @@ actions: condition: msix-install-error debug_message: 'Found evidence of MSIX install error: $error, adding msix tag' tag: 'msix' + + - when: + condition: msix-bad-install-state + user_message: | + 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? + + ``` + Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/triage/install-latest-wsl.ps1" -OutFile install-latest-wsl.ps1 + Set-ExecutionPolicy Bypass -Scope Process -Force + .\install-latest-wsl.ps1 + ``` + + + tag: 'msix' diff --git a/triage/install-latest-wsl.ps1 b/triage/install-latest-wsl.ps1 new file mode 100644 index 00000000..09ca017d --- /dev/null +++ b/triage/install-latest-wsl.ps1 @@ -0,0 +1,50 @@ +#Requires -RunAsAdministrator + +# This script downloads and installs the latest version of the WSL MSI package + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version Latest + +$release = Invoke-WebRequest 'https://api.github.com/repos/microsoft/WSL/releases/latest' | ConvertFrom-Json +$systeminfo = & systeminfo | findstr /C:"System Type" +if ($systeminfo.contains('x64')) +{ + $target = '.x64.msi' +} elseif ($systeminfo.contains('arm64')) +{ + $target = '.arm64.msi' +} else +{ + throw 'Failed to determine system type ($systeminfo)' +} + +[array]$assets = $release.assets | Where-Object { $_.name.ToLower().endswith('.x64.msi')} +if ($assets.count -ne 1) +{ + throw 'Failed to find asset ($assets)' +} + +$target = "$env:tmp\$($assets.name)" +Write-Host "Downloading $($assets.name) to $target" + +$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" +$headers.Add('Accept','application/octet-stream') + +Invoke-WebRequest $assets.url -Out $target -Headers $headers + +$MSIArguments = @( + "/i" + $target + "/qn" + "/norestart" +) + +$exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode +if ($exitCode -Ne 0) +{ + throw "Failed to install package: $exitCode" +} + +Write-Host 'Installation complete' + +Remove-Item $target -Force