Skip to content

Fix MSBuildEventSource#13030

Merged
YuliiaKovalova merged 2 commits intodotnet:mainfrom
dfederm:fix-event-source
Jan 19, 2026
Merged

Fix MSBuildEventSource#13030
YuliiaKovalova merged 2 commits intodotnet:mainfrom
dfederm:fix-event-source

Conversation

@dfederm
Copy link
Contributor

@dfederm dfederm commented Jan 15, 2026

I'm seeing this exception:

System.TypeInitializationException: The type initializer for 'Microsoft.Build.Eventing.MSBuildEventSource' threw an exception.
---> System.MissingMethodException: Method not found: 'Void System.Diagnostics.Tracing.EventSource..ctor(System.String, System.Guid)'.
   at Microsoft.Build.Eventing.MSBuildEventSource..ctor()
   at Microsoft.Build.Eventing.MSBuildEventSource..ctor()
   at Microsoft.Build.Eventing.MSBuildEventSource..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Build.Graph.ProjectGraph.<>c__DisplayClass41_0.<.ctor>g__BeginMeasurement|1()
   at Microsoft.Build.Graph.ProjectGraph..ctor(IEnumerable`1 entryPoints, ProjectCollection projectCollection, ProjectInstanceFactoryFunc projectInstanceFactory, Int32 degreeOfParallelism, CancellationToken cancellationToken)
   at Microsoft.Build.Graph.ProjectGraph..ctor(IEnumerable`1 entryPoints, ProjectCollection projectCollection, ProjectInstanceFactoryFunc projectInstanceFactory)

In ILSpy I see Microsoft.Build.Framework.dll 18.3.0-preview-26055-101+e64f84d6312cdaf227d26aeabfa4817862404d59 having:

    private MSBuildEventSource()
        : base("Microsoft-Build", new Guid(3561627800u, 33311, 22536, 76, 234, 30, 36, 233, 130, 202, 55))
    {
    }

But in C:\Program Files\dotnet\shared\Microsoft.NETCore.App\10.0.1\System.Private.CoreLib.dll (loaded in .NET 10) I see:

internal EventSource(Guid eventSourceGuid, string eventSourceName)
    : this(eventSourceGuid, eventSourceName, EventSourceSettings.EtwManifestEventFormat)
{
}

It's both internal and the args are backwards...

I believe this was introduced in #12886.

Which pulls in this change: dotnet/runtime#121180

That seems to introduce a source generator which calls the internal ctor of EventSource (and with different order). As that's internal to .NET, I expect it was not intended to be applied here in MSBuild.

This change simply reverts the change to MSBuildEventSource.

Copilot AI review requested due to automatic review settings January 15, 2026 01:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a MissingMethodException in MSBuildEventSource that was introduced by a previous change (PR #12886) that attempted to use the .NET runtime's EventSource source generator. The source generator was calling an internal EventSource constructor that is not available in the public API, causing runtime failures when MSBuild is used with .NET 10.

Changes:

  • Removed the partial keyword from MSBuildEventSource class declaration
  • Added an explicit private parameterless constructor to restore the original functionality

@AR-May
Copy link
Member

AR-May commented Jan 15, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@YuliiaKovalova YuliiaKovalova merged commit d6f451b into dotnet:main Jan 19, 2026
10 checks passed
This was referenced Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants