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

  1. Install Visual Studio (Community/Professional/Enterprise) with the .NET desktop and MAUI workloads.
  2. If only Preview is installed, pass includePrerelease=true (or the equivalent cake argument) so VSWhereLatest considers it.
  3. Run `vswhere -latest -prerelease` manually to confirm what vswhere can see and reconcile with the installed edition.
  4. 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

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


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/bae3a80be848f8c4. Report an issue: GitHub.