Skip to content

Explain need for Locator API call #4935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/msbuild/updating-an-existing-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Do not specify `ExcludeAssets=runtime` for the Microsoft.Build.Locator package.

### Register instance before calling MSBuild

Add a call to the Locator API before calling any method that uses MSBuild.
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is overly detailed and would be better off with a good and bad example. Writing one up.

Copy link
Contributor Author

@Forgind Forgind Mar 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's just because I think this sort of thing is really cool, but I would appreciate that level of detail if for no other reason than that I'd wonder why Microsoft would put in arbitrary requirements, and this would clarify that. That being said, an example would help, and you could certainly look at it faster.


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

Expand Down