Where is MSBuild.exe located? Finding the MSBuild path
Codemia Knowledge Hub ·
There is no single fixed path to MSBuild.exe. With Visual Studio 2022 it is usually under C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\ (or the folder for your edition), and Visual Studio 2026 installs under a 18 folder instead of 2022, but the exact location depends on the edition, whether you installed Visual Studio or Build Tools, and whether you use older .NET Framework tooling or the dotnet workflow. In scripts, find it with vswhere.exe instead of hard-coding it.
Typical locations on modern Windows
or:
The edition folder can be Community, Professional, Enterprise or BuildTools. Older systems may use Program Files (x86) depending on the installed tooling.
Finding MSBuild with vswhere
Microsoft ships vswhere.exe specifically to locate Visual Studio components, and it is the most reliable approach for scripts that must work across developer machines and build agents:
It returns the installed MSBuild path without guessing the edition or year.
Using the Developer Command Prompt
A Visual Studio Developer Command Prompt or Developer PowerShell usually puts MSBuild on PATH for that session, so you can run:
This is convenient for interactive work because the environment is already set up for tool discovery, SDK lookup and other Visual Studio components. A regular shell does not get this setup.
dotnet build for SDK-style projects
Many modern .NET projects do not need MSBuild.exe called directly. dotnet build invokes the underlying build system and works across Windows, Linux and macOS:
For SDK-style projects that do not rely on Visual Studio-specific targets, dotnet build is usually the better default. Direct MSBuild.exe calls still matter for older solutions, specialized targets and some enterprise build scripts.
The old .NET Framework path
Some examples point to a .NET Framework path:
It exists on some systems but is often wrong for modern Visual Studio builds, because it may not match the toolset the solution expects, especially when the build depends on newer workloads or targets installed with Visual Studio.
Discovering MSBuild in a build script
A robust script finds MSBuild and fails clearly when it is missing:
Build agents often have Build Tools installed with a different directory layout from developer workstations, so this is much safer than checking in a machine-specific absolute path.
Related reading
- Path.Combine absolute with relative path strings
- Path.Combine and the dot notation
- Path.Combine for URLs?
- Patterns for Multithreaded Network Server in C
- Pause and Resume Subscription on cold IObservable
- Performance of direct virtual call vs. interface call in C
- Performance of Find vs. FirstOrDefault
- Performance of ReceiveAsync vs. BeginReceive

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.