{"record":{"id":"fdec483ed27447c5","repo":"dotnet/maui","slug":"if-no-app-was-specified-an-app-must-be-provided","errorCode":null,"errorMessage":"If no app was specified, an app must be provided.","messagePattern":"If no app was specified, an app must be provided\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/windows.cake","lineNumber":671,"sourceCode":"\t.IsDependentOn(\"buildOnly\");\n\nTask(\"test\")\n\t.IsDependentOn(\"buildOnly\")\n\t.IsDependentOn(\"testOnly\");\n\nTask(\"buildAndTest\")\n\t.IsDependentOn(\"buildOnly\")\n\t.IsDependentOn(\"testOnly\");\n\nTask(\"SetupTestPaths\")\n\t.Does(() => {\n\n\t// UI Tests\n\tif (string.IsNullOrEmpty(TEST_APP) )\n\t{\n\t\tif (string.IsNullOrEmpty(TEST_APP_PROJECT.FullPath))\n\t\t{\n\t\t\tthrow new Exception(\"If no app was specified, an app must be provided.\");\n\t\t}\n\n\t\tvar winVersion = $\"{DotnetVersion}-windows{windowsVersion}\";\n\t\tvar binDir = TEST_APP_PROJECT.GetDirectory().Combine(\"Controls.TestCases.HostApp\").Combine(CONFIGURATION + \"/\" + winVersion).Combine(DOTNET_PLATFORM);\n\t\tInformation(\"BinDir: {0}\", binDir);\n\t\tvar apps = GetFiles(binDir + \"/*.exe\").Where(c => !c.FullPath.EndsWith(\"createdump.exe\"));\n\t\tif (apps.Count() == 0) \n\t\t{\n\t\t\tvar arcadeBin = new DirectoryPath(\"../../artifacts/bin/\");\n\t\t\tif(TEST_APP_PROJECT.FullPath.Contains(\"Controls.TestCases.HostApp\"))\n\t\t\t{\n\t\t\t\tbinDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/Controls.TestCases.HostApp/\" + CONFIGURATION + \"/\" + winVersion).Combine(DOTNET_PLATFORM));\n\t\t\t}\n\n\t\t\tif(PROJECT.FullPath.Contains(\"Controls.DeviceTests\"))\n\t\t\t{\n\t\t\t\tbinDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/Controls.DeviceTests/\" + CONFIGURATION + \"/\" + winVersion).Combine(DOTNET_PLATFORM));\n\t\t\t}","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/windows.cake#L653-L689","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (missing both)\ndotnet cake --target=testOnly\n// after\ndotnet cake --target=buildAndTest --TEST_APP_PROJECT=src/Controls.TestCases.HostApp/Controls.TestCases.HostApp.csproj --CONFIGURATION=Release","handlingStrategy":"validation","validationCode":"// Before running the Cake target, verify TEST_APP or TEST_APP_PROJECT is set\nif (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(\"TEST_APP\")) &&\n    string.IsNullOrEmpty(Environment.GetEnvironmentVariable(\"TEST_APP_PROJECT\")))\n{\n    Console.Error.WriteLine(\"Set TEST_APP (path to .exe) or TEST_APP_PROJECT (.csproj path).\");\n    Environment.Exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cake","build","windows","configuration","test-runner"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}