-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Summary
Add a zero-configuration option for MSBuildLocator that automatically registers a default MSBuild instance without requiring an explicit call to MSBuildLocator.RegisterDefaults().
Motivation
Currently, every consumer of MSBuildLocator must explicitly call MSBuildLocator.RegisterDefaults() (or one of the other Register* methods) before using any MSBuild APIs. For users who don't need to customize which MSBuild instance is used, this is unnecessary ceremony.
A common question from new users: "Why do I need to call RegisterDefaults() if I never customize the MSBuild location?"
For the majority use case where the default behavior is acceptable, requiring explicit initialization adds friction without providing value.
Proposed Solution
Use a module initializer to automatically register a default MSBuild instance when the assembly loads.
Opt-out mechanism
Introduce an MSBuild property to control this behavior:
<MSBuildLocatorGenerateDefaultInitialization>false</MSBuildLocatorGenerateDefaultInitialization>
When set to false, the automatic initialization file would not be generated, allowing users to retain full control over registration timing and configuration.