{"record":{"id":"3a134f2fb771da45","repo":"dotnet/maui","slug":"error-couldn-t-find-cer-or-msix-file","errorCode":null,"errorMessage":"Error: Couldn't find .cer or .msix file","messagePattern":"Error: Couldn't find \\.cer or \\.msix file","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/windows.cake","lineNumber":456,"sourceCode":"\t\t\t}\n\t\t\tif(PROJECT.FullPath.Contains(\"Graphics.DeviceTests\"))\n\t\t\t{\n\t\t\t\tprojectDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/Graphics.DeviceTests/\" + CONFIGURATION + \"/\"));\n\t\t\t}\n\t\t\tif(PROJECT.FullPath.Contains(\"MauiBlazorWebView.DeviceTests\"))\n\t\t\t{\n\t\t\t\tprojectDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/MauiBlazorWebView.DeviceTests/\" + CONFIGURATION + \"/\"));\n\t\t\t}\t\n\t\t\tif(PROJECT.FullPath.Contains(\"Essentials.DeviceTests\"))\n\t\t\t{\n\t\t\t\tprojectDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/Essentials.DeviceTests/\" + CONFIGURATION + \"/\"));\n\t\t\t}\n\t\t\tcerPaths = GetFiles(projectDir.FullPath + \"/**/AppPackages/*/*.cer\");\n\t\t    msixPaths = GetFiles(projectDir.FullPath + \"/**/AppPackages/*/*.msix\");\n\t\t\tif(cerPaths.Count() == 0 || msixPaths.Count() == 0)\n\t\t\t{\n\t\t\t\tError(\"Error: Couldn't find .cer or .msix file\");\n\t\t\t\tthrow new Exception(\"Error: Couldn't find .cer or .msix file\");\n\t\t\t}\n\t\t}\n\n\t\tvar msixPath = msixPaths.First();\n\t\tvar cerPath = cerPaths.First();\n\t\tInformation($\"Found MSIX, installing: {msixPath}\");\n\n\t\tint InstallAppxPackage(FilePath path) {\n\t\t\tvar absPath = MakeAbsolute(path).FullPath;\n\t\t\tInformation(\"Installing MSIX: {0}\", absPath);\n\t\t\t// $ProgressPreference='SilentlyContinue' suppresses Add-AppxPackage's\n\t\t\t// progress output which otherwise chokes cake's stdout pipe.\n\t\t\treturn StartProcess(\"powershell\",\n\t\t\t\t\"-NoProfile -Command \\\"$ProgressPreference='SilentlyContinue'; Add-AppxPackage -Path '\" + absPath + \"'; if (-not $?) { exit 1 }\\\"\");\n\t\t}\n\n\t\t// Install dependencies\n\t\tvar dependencies = GetFiles(projectDir.FullPath + \"/**/AppPackages/**/Dependencies/x64/*.msix\");","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/windows.cake#L438-L474","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: two lookups then throw with no detail about what was searched\ncerPaths = GetFiles(projectDir.FullPath + \"/**/AppPackages/*/*.cer\");\nmsixPaths = GetFiles(projectDir.FullPath + \"/**/AppPackages/*/*.msix\");\nif(cerPaths.Count() == 0 || msixPaths.Count() == 0)\n    throw new Exception(\"Error: Couldn't find .cer or .msix file\");\n\n// after: report which artifact is missing and where we looked\nvar cerOk = cerPaths.Count() > 0;\nvar msixOk = msixPaths.Count() > 0;\nif (!cerOk || !msixOk)\n    throw new Exception($\"Missing {(cerOk ? \"\" : \".cer \")}{(msixOk ? \"\" : \".msix \")}under {projectDir}. Build the MSIX package first.\");","handlingStrategy":"validation","validationCode":"// After build, assert the AppPackages output exists before install\nvar cer = GetFiles(projectDir + \"/**/AppPackages/*/*.cer\");\nvar msix = GetFiles(projectDir + \"/**/AppPackages/*/*.msix\");\nif (!cer.Any() || !msix.Any())\n    throw new Exception($\"MSIX/cer missing in {projectDir}. Build with packaging enabled and GenerateMsixCert run.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cake","windows","msix","build-artifacts","packaging","certificate"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}