You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/msbuild/find-and-use-msbuild-versions.md
+16-5Lines changed: 16 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -23,13 +23,13 @@ If you redistribute *Microsoft.Build.Locator.dll* with your application, you won
23
23
24
24
Using the locator API requires a few changes in your project, described below. To see an example of the changes required to update a project, see [the commits made to an example project in the MSBuildLocator repository](https://github.com/Microsoft/MSBuildLocator/commits/example-updating-to-msbuild-15).
25
25
26
-
###Change MSBuild references
26
+
## Change MSBuild references
27
27
28
28
To make sure that MSBuild loads from a central location, you must not distribute its assemblies with your application.
29
29
30
30
The mechanism for changing your project to avoid loading MSBuild from a central location depends on how you reference MSBuild.
31
31
32
-
####Use NuGet packages (preferred)
32
+
### Use NuGet packages (preferred)
33
33
34
34
These instructions assume that you're using [PackageReference-style NuGet references](/nuget/consume-packages/package-references-in-project-files).
35
35
@@ -59,11 +59,11 @@ If you can't use NuGet packages, you can reference MSBuild assemblies that are d
59
59
> [!NOTE]
60
60
> If you're updating from a version of MSBuild prior to 15, MSBuild requires binding redirects for certain assemblies (Microsoft.Build assemblies), but if you reference the Microsoft.Build.Locator package, you ensure that your application automatically uses the required binding redirects to version 15.1.0.0. Binding redirects to this version support MSBuild 15.x, 16.x, and 17.x.
61
61
62
-
###Ensure output is clean
62
+
## Ensure output is clean
63
63
64
64
Build your project and inspect the output directory to make sure that it doesn't contain any *Microsoft.Build.\*.dll* assemblies other than *Microsoft.Build.Locator.dll*, added in the next step.
65
65
66
-
###Add package reference for Microsoft.Build.Locator
66
+
## Add package reference for Microsoft.Build.Locator
67
67
68
68
Add a NuGet package reference for [Microsoft.Build.Locator](https://www.nuget.org/packages/Microsoft.Build.Locator/).
69
69
@@ -75,7 +75,7 @@ Add a NuGet package reference for [Microsoft.Build.Locator](https://www.nuget.or
75
75
76
76
Do not specify `ExcludeAssets=runtime` for the Microsoft.Build.Locator package.
77
77
78
-
###Register instance before calling MSBuild
78
+
## Register instance before calling MSBuild
79
79
80
80
When you're creating a build application for general use, you don't know what versions of Visual Studio, .NET, and MSBuild might be installed on a machine your application is being executed on. The purpose of MSBuildLocator is to find an appropriate installation of MSBuild to use on machines with diverse installation environments. MSBuildLocator allows you to specify some logic to determine which MSBuild to use, but you as the developer of your application need to determine what MSBuild version it requires or can accept, or else provide a way for your users to specify a version, and include logic to translate that choice into appropriate calls to the MSBuildLocator API.
81
81
@@ -115,3 +115,14 @@ You cannot reference any MSBuild types (from the `Microsoft.Build` namespace) in
115
115
```
116
116
117
117
To specify an MSBuild instance, you can select a result of `MSBuildLocator.QueryVisualStudioInstances` to pass to `MSBuildLocator.RegisterInstance` using the custom logic you need.
118
+
119
+
## Next steps
120
+
121
+
Learn about MSBuild APIs by consulting the MSBuild API Reference:
0 commit comments