Microsoft.Build.Locator 1.11.1
Microsoft.Build.Locator
Microsoft.Build.Locator helps you locate and register MSBuild assemblies provided with Visual Studio or the .NET SDK. This is essential when you need to use MSBuild APIs in your application to evaluate or build projects.
Why do I need this?
When using MSBuild's .NET API to load and build projects, you need access to the SDKs and build logic distributed with Visual Studio or the .NET SDK, not just the MSBuild APIs. MSBuildLocator helps you find these installations and set up your application to use them, ensuring your code gets the same view of projects as MSBuild.exe, dotnet build, or Visual Studio.
Quick Start
Before using any MSBuild APIs, register MSBuild assemblies:
using Microsoft.Build.Locator;
using Microsoft.Build.Evaluation;
// Register defaults before using any MSBuild types
MSBuildLocator.RegisterDefaults();
// Now you can safely use MSBuild APIs.
// NOTE: due the the way that the CLR loads assemblies, you MUST
// register MSBuild through Locator before any types from
// the MSBuild assemblies are used in your application.
// The safest way to ensure this is to put any MSBuild API
// access into a separate method.
LoadProject();
void LoadProject()
{
var project = new Project("MyProject.csproj");
...
}
For more control over which MSBuild instance to use:
using Microsoft.Build.Locator;
// Query available MSBuild instances
var instances = MSBuildLocator.QueryVisualStudioInstances().ToArray();
// Register a specific instance
var instance = instances.OrderByDescending(i => i.Version).First();
MSBuildLocator.RegisterInstance(instance);
Documentation
For complete documentation, see Use Microsoft.Build.Locator on Microsoft Learn.
Samples
See the BuilderApp sample for a full exploration of the MSBuildLocator library and capabilities.
Showing the top 20 packages that depend on Microsoft.Build.Locator.
| Packages | Downloads |
|---|---|
|
Microsoft.VisualStudio.Web.CodeGeneration.Utils
Contains utilities used by ASP.NET Core Code Generation packages.
|
1 |
.NET Framework 4.6
- No dependencies.
.NET 8.0
- No dependencies.
| Version | Downloads | Last updated |
|---|---|---|
| 1.11.1 | 1 | 11/21/2025 |
| 1.10.12 | 0 | 11/06/2025 |
| 1.10.2 | 0 | 10/04/2025 |
| 1.9.1 | 0 | 03/31/2025 |
| 1.8.1 | 0 | 03/31/2025 |
| 1.7.8 | 0 | 03/14/2024 |
| 1.7.1 | 0 | 02/06/2024 |
| 1.6.10 | 0 | 09/20/2023 |
| 1.6.1 | 0 | 08/30/2023 |
| 1.5.32-g4ed1bab6ff | 0 | 08/25/2023 |
| 1.5.6 | 0 | 08/29/2023 |
| 1.5.5 | 0 | 09/06/2022 |
| 1.5.3 | 0 | 08/11/2022 |
| 1.4.10-g38d95f4814 | 0 | 08/08/2022 |
| 1.4.6-g7150a203a1 | 0 | 08/05/2022 |
| 1.4.1 | 0 | 01/21/2021 |
| 1.3.2 | 0 | 12/17/2020 |
| 1.2.15-ge4e3fc36c9 | 0 | 11/09/2020 |
| 1.2.6 | 0 | 08/14/2019 |
| 1.2.2 | 0 | 04/03/2019 |
| 1.1.2 | 0 | 12/07/2018 |
| 1.0.31 | 0 | 09/12/2018 |
| 1.0.18 | 0 | 05/29/2018 |
| 1.0.13 | 0 | 04/05/2018 |
| 1.0.7-preview-ge60d679b53 | 0 | 02/22/2018 |
| 1.0.5-preview-gc41880f6f8 | 0 | 02/15/2018 |