dotnet/maui · error · Exception
Error: Couldn't find .cer or .msix file
Error message
Error: Couldn't find .cer or .msix file
What it means
Thrown during packaged-test install when neither the project's AppPackages folder nor the arcade bin fallback (artifacts/bin/<project>/<config>/) contains both a .cer and a .msix file. The build that should have produced the signed MSIX package (with GenerateMsixCert + packaging enabled) did not emit the expected AppPackages output, so sideloading cannot proceed.
Source
Thrown at eng/devices/windows.cake:456
}
if(PROJECT.FullPath.Contains("Graphics.DeviceTests"))
{
projectDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/Graphics.DeviceTests/" + CONFIGURATION + "/"));
}
if(PROJECT.FullPath.Contains("MauiBlazorWebView.DeviceTests"))
{
projectDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/MauiBlazorWebView.DeviceTests/" + CONFIGURATION + "/"));
}
if(PROJECT.FullPath.Contains("Essentials.DeviceTests"))
{
projectDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/Essentials.DeviceTests/" + CONFIGURATION + "/"));
}
cerPaths = GetFiles(projectDir.FullPath + "/**/AppPackages/*/*.cer");
msixPaths = GetFiles(projectDir.FullPath + "/**/AppPackages/*/*.msix");
if(cerPaths.Count() == 0 || msixPaths.Count() == 0)
{
Error("Error: Couldn't find .cer or .msix file");
throw new Exception("Error: Couldn't find .cer or .msix file");
}
}
var msixPath = msixPaths.First();
var cerPath = cerPaths.First();
Information($"Found MSIX, installing: {msixPath}");
int InstallAppxPackage(FilePath path) {
var absPath = MakeAbsolute(path).FullPath;
Information("Installing MSIX: {0}", absPath);
// $ProgressPreference='SilentlyContinue' suppresses Add-AppxPackage's
// progress output which otherwise chokes cake's stdout pipe.
return StartProcess("powershell",
"-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; Add-AppxPackage -Path '" + absPath + "'; if (-not $?) { exit 1 }\"");
}
// Install dependencies
var dependencies = GetFiles(projectDir.FullPath + "/**/AppPackages/**/Dependencies/x64/*.msix");View on GitHub (pinned to f377ff1c5e)
Solutions
- Run the build target with MSIX packaging enabled and the same CONFIGURATION as the install step, then confirm AppPackages/<name>_<version>_Test/ contains both .cer and .msix.
- Ensure GenerateMsixCert ran (packaged runs depend on it) so the package is signed and the .cer is emitted alongside.
- Verify the project name appears in one of the PROJECT.FullPath.Contains(...) branches; if it is a new project, add a fallback mapping or fix the project dir.
- Check CONFIGURATION is not empty/Default — an empty config produces a path like artifacts/bin/Controls.DeviceTests// that matches nothing.
Example fix
// before: two lookups then throw with no detail about what was searched
cerPaths = GetFiles(projectDir.FullPath + "/**/AppPackages/*/*.cer");
msixPaths = GetFiles(projectDir.FullPath + "/**/AppPackages/*/*.msix");
if(cerPaths.Count() == 0 || msixPaths.Count() == 0)
throw new Exception("Error: Couldn't find .cer or .msix file");
// after: report which artifact is missing and where we looked
var cerOk = cerPaths.Count() > 0;
var msixOk = msixPaths.Count() > 0;
if (!cerOk || !msixOk)
throw new Exception($"Missing {(cerOk ? "" : ".cer ")}{(msixOk ? "" : ".msix ")}under {projectDir}. Build the MSIX package first."); Defensive patterns
Strategy: validation
Validate before calling
// After build, assert the AppPackages output exists before install
var cer = GetFiles(projectDir + "/**/AppPackages/*/*.cer");
var msix = GetFiles(projectDir + "/**/AppPackages/*/*.msix");
if (!cer.Any() || !msix.Any())
throw new Exception($"MSIX/cer missing in {projectDir}. Build with packaging enabled and GenerateMsixCert run."); Prevention
- Keep CONFIGURATION identical between the MSIX build and the install step.
- Ensure GenerateMsixCert runs before packaging so the .cer is emitted.
- Add new DeviceTests projects to the Contains() fallback list or fix the project dir resolution.
When it happens
Trigger: Running the packaged test install without first building the MSIX; building with packaging disabled (no AppPackages dir generated); building into a configuration other than CONFIGURATION so the fallback path is wrong; GenerateMsixCert not run so signing/packaging was skipped; project name not matching any of the Contains() checks so the fallback points nowhere useful.
Common situations: CONFIGURATION mismatch (Debug vs Release) between build and test steps; missing /p:AppxPackage=true or the packaging targets; a clean wiping AppPackages; new DeviceTests project not yet added to the Contains() fallback list; building unpackaged by default.
Related errors
- Cert {certificateThumbprint} exists in LocalMachine\TrustedP
- Failed to install signing cert into LocalMachine\TrustedPeop
- Failed to install app MSIX (exit code {installExit}): {msixP
- ActivateApplication failed (HRESULT=0x{0:X8})
- No test assembly found.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/3a134f2fb771da45.
Report an issue: GitHub.