Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proactively check for loaded MSBuild (#14)
The .NET assembly loader ensures that any assembly referenced by a method is loaded before the method is called. This requires that MSBuildLocator be called **before any method that references MSBuild**. That's a confusing requirement, and easy to forget. But it's easy to check for, and since we expect the locator to be called roughly once per process, not too expensive to check for at `RegisterInstance` time. Produces an error like ``` Unhandled Exception: System.InvalidOperationException: Microsoft.Build.Locator.MSBuildLocator.RegisterInstance was called, but MSBuild assemblies were already loaded. Ensure that RegisterInstance is called before any method that directly references types in the Microsoft.Build namespace has been called. Loaded MSBuild assemblies: Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a at Microsoft.Build.Locator.MSBuildLocator.RegisterInstance(VisualStudioInstance instance) at Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults() at MultiProcBuilderApplication.Program.Main(String[] args) in s:\work\MultiProcBuilderApplication\MultiProcBuilderApplication\Program.cs:line 13 ```
- Loading branch information