Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Automatic MSBuild Registration via Module Initializer

Open
#371 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
build-system

Research direction

Start by reviewing the existing MSBuildLocator.RegisterDefaults() and other Register* entry points, then examine how a module initializer and the MSBuildLocatorGenerateDefaultInitialization property could control generated initialization. Done means a default MSBuild instance is registered automatically by default, while setting the property to false preserves explicit registration control.

Written by the indexing model from the issue text.

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.

Dominant language
C#
Stars
262
Forks
91
Avg merge
11d 22h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/MSBuildLocator

All issues in microsoft/MSBuildLocator

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.