dotnet/maui · error · Exception
Unable to find Visual Studio!
Error message
Unable to find Visual Studio!
What it means
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.
Source
Thrown at eng/cake/dotnet.cake:818
}
}
if (IsCIBuild())
{
Error("This target should not run on CI.");
return;
}
if (localDotnet)
{
SetDotNetEnvironmentVariables();
}
if (IsRunningOnWindows())
{
var vsLatest = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = includePrerelease, });
if (vsLatest == null)
throw new Exception("Unable to find Visual Studio!");
StartProcess(vsLatest.CombineWithFilePath("./Common7/IDE/devenv.exe"), sln);
}
else
{
StartProcess("open", new ProcessSettings { Arguments = sln, EnvironmentVariables = GetDotNetEnvironmentVariables() });
}
}
// NOTE: These methods work as long as the "dotnet" target has already run
void RunMSBuildWithDotNet(
string sln,
Dictionary<string, string> properties = null,
string target = "Build",
bool warningsAsError = false,
bool restore = true,View on GitHub (pinned to f377ff1c5e)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check VS availability on Windows
if (IsRunningOnWindows()) {
var vsLatest = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = includePrerelease });
if (vsLatest == null) {
Warning("Visual Studio not found; cannot open solution. Install VS or pass includePrerelease=true.");
return;
}
} Prevention
- 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.
When it happens
Trigger: IsRunningOnWindows() is true and `VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = includePrerelease })` returns null — no VS installation matches the query.
Common situations: 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.
Related errors
- PowerShell Core (pwsh) is not installed. Please install it t
- PowerShell Core (pwsh) is required on non-Windows platforms.
- Environment variable 'ANDROID_SDK_ROOT' or 'ANDROID_HOME' mu
- JAVA_HOME environment variable isn't set. Set it to your JDK
- Failed to download the package.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/bae3a80be848f8c4.
Report an issue: GitHub.