dotnet/maui · error · Exception

Failed to install app MSIX (exit code {installExit}): {msixP

Error message

Failed to install app MSIX (exit code {installExit}): {msixPath}

What it means

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.

Source

Thrown at eng/devices/windows.cake:489

		}

		// Install dependencies
		var dependencies = GetFiles(projectDir.FullPath + "/**/AppPackages/**/Dependencies/x64/*.msix");
		foreach (var dep in dependencies) {
			try {
				var depExit = InstallAppxPackage(dep);
				if (depExit != 0) {
					Warning($"Failed to install dependency (exit code {depExit}): {dep}");
				}
			} catch {
				Warning($"Failed to install dependency: {dep}");
			}
		}

		// Install the DeviceTests app
		var installExit = InstallAppxPackage(msixPath);
		if (installExit != 0) {
			throw new Exception($"Failed to install app MSIX (exit code {installExit}): {msixPath}");
		}

		if (isControlsProjectTestRun)
		{
			// Start the app once to trigger the discovery of the test categories; we wait
			// for the actual app process to exit, then read the categories file.
			if (!LaunchPackagedAndWait($"\"{testResultsFile}\" \"-1\"", "category discovery", 120)) {
				throw new Exception("Category discovery run did not complete successfully");
			}

			if (!FileExists(testsToRunFile)) {
				throw new Exception("Test categories file was not created during discovery phase");
			}

			var expectedCategories = System.IO.File.ReadAllLines(testsToRunFile);
			var filteredCategories = FilterCategories(expectedCategories);
			
			if (filteredCategories.Length == 0) {

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Run Add-AppxPackage manually on the MSIX path to get the full PowerShell error (the script only captures the exit code).
  2. Ensure GenerateMsixCert ran and the signing cert is in LocalMachine\TrustedPeople; a signature mismatch is the most common cause.
  3. Uninstall any prior copy: run the uninstallPS action (Get-AppxPackage/Remove-AppxPackage) or 'Get-AppxPackage *<PACKAGEID>* | Remove-AppxPackage' before installing.
  4. Check the dependency Warning lines — if a framework dependency failed, install it manually and investigate why Add-AppxPackage rejected it.
  5. Verify the MSIX architecture matches the OS (x64 package on x64 host).

Example fix

// before: exit code only, no diagnostic detail
return StartProcess("powershell",
    "-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; Add-AppxPackage -Path '" + absPath + "'; if (-not $?) { exit 1 }\");

// after: capture and surface the PowerShell error stream
return StartProcess("powershell",
    "-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 }\");
Defensive patterns

Strategy: try-catch

Validate before calling

// Before installing, uninstall any prior copy and verify the cert is trusted
var prior = StartProcess("powershell", "-NoProfile -Command \"Get-AppxPackage -Name " + PACKAGEID + " | Remove-AppxPackage\");
if (!IsCertInTrustedPeople(certificateThumbprint))
    throw new Exception("Signing cert not in LocalMachine\\TrustedPeople; run GenerateMsixCert.");

Try / catch

try { var exit = InstallAppxPackage(msixPath); if (exit != 0) throw new Exception($"MSIX install failed (exit {exit}). Run Add-AppxPackage manually for details: {msixPath}"); }
catch (Exception ex) when (ex.Message.Contains("exit")) { /* surface full Add-AppxPackage error */ throw; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/365fe4c599decba6. Report an issue: GitHub.