dotnet/maui · error · Exception
Test categories file was not created during discovery phase
Error message
Test categories file was not created during discovery phase
What it means
Thrown in the packaged Controls test path after the category-discovery app exited (LaunchPackagedAndWait returned true) but the testsToRunFile does not exist. The discovery invocation is supposed to make the app write its test-category list to a file; the file's absence means the app ran but never wrote the categories — typically a startup crash after activation, a wrong output path, or the discovery mode (-1) not being honored.
Source
Thrown at eng/devices/windows.cake:501
}
}
// 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) {
Information("No categories to run after applying filter. Skipping test execution.");
return;
}
Information($"Will run {filteredCategories.Length} filtered categories out of {expectedCategories.Length} total");
for (int i = 0; i < filteredCategories.Length; i++)
{
var categoryName = filteredCategories[i];
// Find the original index of this category in the expected categories
var originalIndex = Array.IndexOf(expectedCategories, categoryName);
var expectedResultFile = testResultsPath + $"\\TestResults-{PACKAGEID.Replace(".", "_")}_{categoryName}.xml";View on GitHub (pinned to f377ff1c5e)
Solutions
- Compare the testsToRunFile path the script checks against the path the app actually writes (search the whole results dir and temp for any categories file).
- Launch the packaged app with the discovery args manually and capture its output/Event Viewer to find where it crashes before writing.
- Confirm the app's discovery-mode argument (-1) still matches the app's expected sentinel value after recent changes.
- Verify the packaged app has write access to the testResultsPath (packaged apps have restricted write locations).
Defensive patterns
Strategy: validation
Validate before calling
// After discovery exits, verify the file and report its expected path
if (!FileExists(testsToRunFile))
throw new Exception($"Discovery did not write {testsToRunFile}. Launch the packaged app manually to see the crash."); Prevention
- Keep the testsToRunFile path consistent between the script and the app's discovery writer.
- Ensure the packaged app can write to the results path (sandbox restrictions).
- Confirm the -1 discovery sentinel matches the app's current contract.
When it happens
Trigger: The app activated and exited but crashed before reaching the category-enumeration/discovery code; testsToRunFile path resolves to a different location than the app writes to; the app launched in normal (not discovery) mode because the -1 argument was not parsed; write permissions on the results dir.
Common situations: A recent code change causing an early crash after activation; CONFIGURATION/results path mismatch so the file is written elsewhere; the app's discovery-mode argument contract changed but the script still passes -1; results dir on a path the packaged app (sandboxed) cannot write to.
Related errors
- Category discovery run did not complete successfully
- Cert {certificateThumbprint} exists in LocalMachine\TrustedP
- Failed to install signing cert into LocalMachine\TrustedPeop
- Error: Couldn't find .cer or .msix file
- Failed to install app MSIX (exit code {installExit}): {msixP
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/05503b357843cd29.
Report an issue: GitHub.