dotnet/maui · error · Exception
If no app was specified, an app must be provided.
Error message
If no app was specified, an app must be provided.
What it means
Thrown by the Cake build script's SetupTestPaths task when neither the TEST_APP environment variable nor the TEST_APP_PROJECT path resolves to a value. The build needs at least one of these to locate the compiled Windows .exe that UI tests will run against. Without it, there is no target application binary to exercise.
Source
Thrown at eng/devices/windows.cake:671
.IsDependentOn("buildOnly");
Task("test")
.IsDependentOn("buildOnly")
.IsDependentOn("testOnly");
Task("buildAndTest")
.IsDependentOn("buildOnly")
.IsDependentOn("testOnly");
Task("SetupTestPaths")
.Does(() => {
// UI Tests
if (string.IsNullOrEmpty(TEST_APP) )
{
if (string.IsNullOrEmpty(TEST_APP_PROJECT.FullPath))
{
throw new Exception("If no app was specified, an app must be provided.");
}
var winVersion = $"{DotnetVersion}-windows{windowsVersion}";
var binDir = TEST_APP_PROJECT.GetDirectory().Combine("Controls.TestCases.HostApp").Combine(CONFIGURATION + "/" + winVersion).Combine(DOTNET_PLATFORM);
Information("BinDir: {0}", binDir);
var apps = GetFiles(binDir + "/*.exe").Where(c => !c.FullPath.EndsWith("createdump.exe"));
if (apps.Count() == 0)
{
var arcadeBin = new DirectoryPath("../../artifacts/bin/");
if(TEST_APP_PROJECT.FullPath.Contains("Controls.TestCases.HostApp"))
{
binDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/Controls.TestCases.HostApp/" + CONFIGURATION + "/" + winVersion).Combine(DOTNET_PLATFORM));
}
if(PROJECT.FullPath.Contains("Controls.DeviceTests"))
{
binDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/Controls.DeviceTests/" + CONFIGURATION + "/" + winVersion).Combine(DOTNET_PLATFORM));
}View on GitHub (pinned to f377ff1c5e)
Solutions
- Set the TEST_APP environment variable to the full path of the built .exe: 'set TEST_APP=C:\path\to\Controls.TestCases.HostApp.exe' before running the Cake target.
- Ensure TEST_APP_PROJECT points to a valid .csproj by passing it as a Cake argument: '--target=buildAndTest --TEST_APP_PROJECT=...Controls.TestCases.HostApp.csproj'.
- Run the 'buildOnly' target first so that the HostApp binary exists in the expected bin output, then run the test target.
- Check that CONFIGURATION, DotnetVersion, windowsVersion, and DOTNET_PLATFORM env vars are set, since the bin path is computed from them and a mismatch prevents auto-discovery.
Example fix
// before (missing both) dotnet cake --target=testOnly // after dotnet cake --target=buildAndTest --TEST_APP_PROJECT=src/Controls.TestCases.HostApp/Controls.TestCases.HostApp.csproj --CONFIGURATION=Release
Defensive patterns
Strategy: validation
Validate before calling
// Before running the Cake target, verify TEST_APP or TEST_APP_PROJECT is set
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEST_APP")) &&
string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEST_APP_PROJECT")))
{
Console.Error.WriteLine("Set TEST_APP (path to .exe) or TEST_APP_PROJECT (.csproj path).");
Environment.Exit(1);
} Prevention
- Always pass --TEST_APP_PROJECT or --TEST_APP as explicit Cake arguments rather than relying on ambient env vars.
- Document required variables in the repo's README or build instructions.
- Use a Cake setup task that validates all required variables and fails early with a clear message.
- In CI, set all test variables explicitly in the pipeline YAML.
When it happens
Trigger: Running the 'buildAndTest' or 'testOnly' Cake target on Windows without setting the TEST_APP env var and without TEST_APP_PROJECT pointing to a valid .csproj. This happens when the test harness is invoked directly (e.g. via 'dotnet cake --target=testOnly') without the pipeline variables that CI normally injects.
Common situations: Running Cake locally without the full CI variable set; TEST_APP_PROJECT not set because the HostApp project was not built or was skipped in a partial build; env vars from a previous shell session were cleared; invoking a subset of targets (e.g. just 'testOnly') that skips the project resolution step.
Related errors
- Error: Couldn't find .exe file
- Error: Building dotnet-samples with NativeAOT is only suppor
- Error: Running UI tests with NativeAOT is only supported in
- Some tests failed. Check the logs or test results.
- UI Test application path not specified.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/fdec483ed27447c5.
Report an issue: GitHub.