{"record":{"id":"365fe4c599decba6","repo":"dotnet/maui","slug":"failed-to-install-app-msix-exit-code-installexit","errorCode":null,"errorMessage":"Failed to install app MSIX (exit code {installExit}): {msixPath}","messagePattern":"Failed to install app MSIX \\(exit code (.+?)\\): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/windows.cake","lineNumber":489,"sourceCode":"\t\t}\n\n\t\t// Install dependencies\n\t\tvar dependencies = GetFiles(projectDir.FullPath + \"/**/AppPackages/**/Dependencies/x64/*.msix\");\n\t\tforeach (var dep in dependencies) {\n\t\t\ttry {\n\t\t\t\tvar depExit = InstallAppxPackage(dep);\n\t\t\t\tif (depExit != 0) {\n\t\t\t\t\tWarning($\"Failed to install dependency (exit code {depExit}): {dep}\");\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tWarning($\"Failed to install dependency: {dep}\");\n\t\t\t}\n\t\t}\n\n\t\t// Install the DeviceTests app\n\t\tvar installExit = InstallAppxPackage(msixPath);\n\t\tif (installExit != 0) {\n\t\t\tthrow new Exception($\"Failed to install app MSIX (exit code {installExit}): {msixPath}\");\n\t\t}\n\n\t\tif (isControlsProjectTestRun)\n\t\t{\n\t\t\t// Start the app once to trigger the discovery of the test categories; we wait\n\t\t\t// for the actual app process to exit, then read the categories file.\n\t\t\tif (!LaunchPackagedAndWait($\"\\\"{testResultsFile}\\\" \\\"-1\\\"\", \"category discovery\", 120)) {\n\t\t\t\tthrow new Exception(\"Category discovery run did not complete successfully\");\n\t\t\t}\n\n\t\t\tif (!FileExists(testsToRunFile)) {\n\t\t\t\tthrow new Exception(\"Test categories file was not created during discovery phase\");\n\t\t\t}\n\n\t\t\tvar expectedCategories = System.IO.File.ReadAllLines(testsToRunFile);\n\t\t\tvar filteredCategories = FilterCategories(expectedCategories);\n\t\t\t\n\t\t\tif (filteredCategories.Length == 0) {","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/windows.cake#L471-L507","documentation":"Thrown after InstallAppxPackage (which runs PowerShell Add-AppxPackage on the MSIX) returns a non-zero exit code. The MSIX could not be installed — common causes are a signature that does not match the trusted cert, a missing dependency, an architecture mismatch, or a prior install of the same package family under a different signature blocking the install.","triggerScenarios":"Add-AppxPackage fails because the package is signed with a cert not in TrustedPeople; a dependency MSIX (in Dependencies/x64) is missing or failed to install first; the MSIX targets a different architecture than the host; an older build of the same package is installed with a different cert and cannot be overwritten.","commonSituations":"GenerateMsixCert not run or cert regenerated so the new signature differs from a previously installed copy; dependency installation warned-and-skipped (the try/catch at line 481 only warns) leaving a required framework missing; building for x64 but running on arm64; CI machine retaining a stale install.","solutions":["Run Add-AppxPackage manually on the MSIX path to get the full PowerShell error (the script only captures the exit code).","Ensure GenerateMsixCert ran and the signing cert is in LocalMachine\\TrustedPeople; a signature mismatch is the most common cause.","Uninstall any prior copy: run the uninstallPS action (Get-AppxPackage/Remove-AppxPackage) or 'Get-AppxPackage *<PACKAGEID>* | Remove-AppxPackage' before installing.","Check the dependency Warning lines — if a framework dependency failed, install it manually and investigate why Add-AppxPackage rejected it.","Verify the MSIX architecture matches the OS (x64 package on x64 host)."],"exampleFix":"// before: exit code only, no diagnostic detail\nreturn StartProcess(\"powershell\",\n    \"-NoProfile -Command \\\"$ProgressPreference='SilentlyContinue'; Add-AppxPackage -Path '\" + absPath + \"'; if (-not $?) { exit 1 }\\\");\n\n// after: capture and surface the PowerShell error stream\nreturn StartProcess(\"powershell\",\n    \"-NoProfile -Command \\\"$ProgressPreference='SilentlyContinue'; $e = $null; try { Add-AppxPackage -Path '\" + absPath + \"' -ErrorAction Stop } catch { $e = $_ }; if ($e) { Write-Error $e; exit 2 }; if (-not $?) { exit 1 }\\\");","handlingStrategy":"try-catch","validationCode":"// Before installing, uninstall any prior copy and verify the cert is trusted\nvar prior = StartProcess(\"powershell\", \"-NoProfile -Command \\\"Get-AppxPackage -Name \" + PACKAGEID + \" | Remove-AppxPackage\\\");\nif (!IsCertInTrustedPeople(certificateThumbprint))\n    throw new Exception(\"Signing cert not in LocalMachine\\\\TrustedPeople; run GenerateMsixCert.\");","typeGuard":null,"tryCatchPattern":"try { var exit = InstallAppxPackage(msixPath); if (exit != 0) throw new Exception($\"MSIX install failed (exit {exit}). Run Add-AppxPackage manually for details: {msixPath}\"); }\ncatch (Exception ex) when (ex.Message.Contains(\"exit\")) { /* surface full Add-AppxPackage error */ throw; }","preventionTips":["Always uninstall the prior package before installing a re-signed one.","Run Add-AppxPackage manually once to surface the real PowerShell error.","Confirm dependency frameworks installed (review dependency Warning lines) before the main install."],"tags":["cake","windows","msix","appx","powershell","install"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}