{"record":{"id":"bae3a80be848f8c4","repo":"dotnet/maui","slug":"unable-to-find-visual-studio","errorCode":null,"errorMessage":"Unable to find Visual Studio!","messagePattern":"Unable to find Visual Studio!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/cake/dotnet.cake","lineNumber":818,"sourceCode":"        }\n    }\n\n    if (IsCIBuild())\n    {\n        Error(\"This target should not run on CI.\");\n        return;\n    }\n\n    if (localDotnet)\n    {\n        SetDotNetEnvironmentVariables();\n    }\n\n    if (IsRunningOnWindows())\n    {\n        var vsLatest = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = includePrerelease, });\n        if (vsLatest == null)\n            throw new Exception(\"Unable to find Visual Studio!\");\n\n        StartProcess(vsLatest.CombineWithFilePath(\"./Common7/IDE/devenv.exe\"), sln);\n    }\n    else\n    {\n\n        StartProcess(\"open\", new ProcessSettings { Arguments = sln, EnvironmentVariables = GetDotNetEnvironmentVariables() });\n    }\n}\n\n// NOTE: These methods work as long as the \"dotnet\" target has already run\n\nvoid RunMSBuildWithDotNet(\n    string sln,\n    Dictionary<string, string> properties = null,\n    string target = \"Build\",\n    bool warningsAsError = false,\n    bool restore = true,","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/cake/dotnet.cake#L800-L836","documentation":"Thrown on Windows when VSWhereLatest returns null, meaning the vswhere tool could not locate any installed Visual Studio (including with pre-release included per the includePrerelease flag). The script needs VS to open the solution in devenv, so it aborts before calling StartProcess on a null path.","triggerScenarios":"IsRunningOnWindows() is true and `VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = includePrerelease })` returns null — no VS installation matches the query.","commonSituations":"A clean Windows machine or CI agent with only VS Build Tools (vswhere may filter by edition), VS installed but not detected due to a corrupt setup, or includePrerelease=false while only a Preview VS is installed.","solutions":["Install Visual Studio (Community/Professional/Enterprise) with the .NET desktop and MAUI workloads.","If only Preview is installed, pass includePrerelease=true (or the equivalent cake argument) so VSWhereLatest considers it.","Run `vswhere -latest -prerelease` manually to confirm what vswhere can see and reconcile with the installed edition.","As a workaround on Windows, skip this open-solution helper and open the .sln directly in your installed VS."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check VS availability on Windows\nif (IsRunningOnWindows()) {\n    var vsLatest = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = includePrerelease });\n    if (vsLatest == null) {\n        Warning(\"Visual Studio not found; cannot open solution. Install VS or pass includePrerelease=true.\");\n        return;\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure VS (with .NET desktop + MAUI workloads) is in the Windows image.","Default includePrerelease=true in environments where only Preview is installed.","Validate with `vswhere -latest -prerelease` in a pipeline setup step."],"tags":["visual-studio","vswhere","windows","environment","dependency"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}