Skip to content

Commit ca9dd12

Browse files
authored
Explain need for Locator API call
Clarify rationale for separating call to Locator API from method using types
1 parent 31eda79 commit ca9dd12

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/msbuild/updating-an-existing-application.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Do not specify `ExcludeAssets=runtime` for the Microsoft.Build.Locator package.
7979

8080
### Register instance before calling MSBuild
8181

82-
Add a call to the Locator API before calling any method that uses MSBuild.
82+
Add a call to the Locator API before calling any method that uses MSBuild. This is important because the just-in-time (JIT) compiler needs to understand the types of the objects it compiles, and when trying to build a project using a specific version of MSBuild, it has to inspect that version before it compiles the code in case those types have changed. Since the JIT compiler works at a method-level granularity, if the call to the Locator API is in the same method as the first use of an MSBuild type (even if it precedes it, and the code involving the type has not yet been executed), the JIT compiler will not be able to JIT the whole method, causing an error. Some types that require the call to the MSBuildLocator API to have already been called include ProjectRootElement, ProjectInstance, and BuildManager.
8383

8484
The simplest way to add the call to the Locator API is to add a call to
8585

0 commit comments

Comments
 (0)