Add MSBuild Server lifecycle node support (binlog format v27)#955
Merged
KirillOsenkov merged 1 commit intoJul 13, 2026
Conversation
Companion to dotnet/msbuild#14156, which records how each build relates to the MSBuild Server node as a dedicated MSBuildServerLifecycleEventArgs under its own BinaryLogRecordKind (binlog format v27). - Read the new MSBuildServerLifecycle record and render it as a dedicated MSBuildServerNode under a "MSBuild Server" folder, with a distinct icon (WPF Generic.xaml + Avalonia). The node exposes Kind (Spawned/Reused/NotUsed), ShortLived, ProcessId, Reason and ReasonCode. - Also read the LoggersRegistered record (binlog format v26) so v26/v27 logs no longer report "Skipped some data unknown to this version of Viewer" for it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
|
if we confirm that we're absolutely sure we want to rev the binlog format, then this looks fine. If @baronfel says go ahead you can undraft and I can merge and publish the viewer first, then we can test binlogs produced by the MSBuild PR to make sure it works, then merge the MSBuild PR then. |
JanProvaznik
added a commit
to JanProvaznik/msbuild
that referenced
this pull request
Jul 13, 2026
…es, tests Applies the multi-agent maintainability review of dotnet#14156: - API surface: make the MSBuildServerLifecycleEventArgs deserialization ctor and BuildManager.DeferredBuildMessage.BuildEvent internal; keep the event type/enum/properties public (third-party loggers depend on them). File-scoped namespace for the new file (per review). - Reason/reasonCode: replace the parallel s_serverNotUsedReason/Code statics and the two lockstep MSBuildClientApp switches with a single ServerNotUsedReason (Message, Code) record produced in one place; collapse CanRunServerBasedOn- CommandLineSwitches reason out-params into it. Reset the reason after it is logged so it cannot leak into a later in-process build. - DeferredBuildMessage: drop the dead importance parameter on the event-backed ctor (importance is taken from the event); set the event's Invalid context at construction so LogDeferredMessages no longer mutates a caller event. - Serialization: add cross-reference "keep in sync" comments at the four serializer sites (node-packet WriteToStream/CreateFromStream and the binlog writer/reader); document that Write(int)/ReadInt32 are 7-bit encoded. - Tests: cover NotUsed (non-null Reason/ReasonCode) and Reused round-trips in the binlog serializer, and add a Framework node-packet WriteToStream/CreateFromStream round-trip (the previously untested IPC path). - Rename the two inconsistent resources to MSBuildServerReason*; fix the self-contradictory MSBuild-Server.md diagnostics wording ("requested"). - Regenerate xlf. Verified end-to-end: a freshly built server MSBuild emits v27 binlogs for the spawned/reused/short-lived/not-used cases, and the msbuildlog StructuredLogger (PR KirillOsenkov/MSBuildStructuredLog#955) reads them and reconstructs the MSBuildServerNode with Kind/ShortLived/ProcessId/Reason/ReasonCode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f723b717-4837-4d3b-bfb1-6929d7d3b94a
Contributor
Author
JanProvaznik
marked this pull request as ready for review
July 13, 2026 18:59
KirillOsenkov
approved these changes
Jul 13, 2026
JanProvaznik
added a commit
to dotnet/msbuild
that referenced
this pull request
Jul 14, 2026
…14156) ### Context It is currently hard to tell from a binary log whether a build used MSBuild Server, whether the server process was freshly spawned or reused, or why the server was *not* used when it was requested. This adds a dedicated, structured build event capturing that lifecycle, including the server process ID. ### Changes A single low-importance event is deferred to the start of each build (so it appears in a binary log and at `-v:diag`, without changing default console output). It is a dedicated, versionable `MSBuildServerLifecycleEventArgs` (its own binary-log record kind) rather than an ad-hoc message, so tooling can recognize and render it structurally while old viewers/consoles still show the human-readable text. The event reports one of: - **Server spawned** — a freshly started server node serving its first build: `MSBuild Server node started for this build (process ID N).` - **Server spawned (short-lived)** — a `/mt` build with node reuse off, which uses a fresh server (for Server GC) that tears itself down afterward: `MSBuild Server node started for this build only; it will shut down afterward (process ID N).` - **Server reused** — an already-running server node reused for this build: `Reusing the running MSBuild Server node for this build (process ID N).` - **Server not used** — the server was requested but the build ran in-process: `MSBuild Server was requested but not used for this build: {reason}.` Reasons cover the server being busy, unreachable, crashed on launch, its state unknown, node reuse being disabled, the `MSBUILDENSURESTDOUTFORTASKPROCESSES` escape hatch, an incompatible invocation, or a command-line parse error. Ordinary builds that never request the server log nothing. `MSBuildServerLifecycleEventArgs` exposes structured fields so third-party loggers and log viewers can branch without parsing localized text: - `Kind` — `Spawned` / `Reused` / `NotUsed` (`MSBuildServerLifecycleKind`). - `ProcessId` — the server node's PID (0 for `NotUsed`). - `ShortLived` — `true` for a spawned server that shuts down after the build. - `Reason` — the localized, human-readable fall-back reason (for `NotUsed`). - `ReasonCode` — a stable, non-localized code for the fall-back cause (e.g. `node-reuse-disabled`, `server-busy`, `server-crashed`), for `NotUsed`. ### Implementation notes - **New event type** `Microsoft.Build.Framework.MSBuildServerLifecycleEventArgs` (+ the `MSBuildServerLifecycleKind` enum), deriving from `BuildMessageEventArgs`. - **Binary log:** new `BinaryLogRecordKind.MSBuildServerLifecycle` with matching writer/reader; `FileFormatVersion` bumped 26 → 27. `MinimumReaderVersion` is unchanged: this is an additive, forward-compatible record, so readers that predate it skip it via the length-prefixed record framing. - **Node transfer:** `LoggingEventType.MSBuildServerLifecycleEvent` is registered so the event can travel from the out-of-proc server node to the client over the existing node-packet channel. - **Deferred path:** `BuildManager.DeferredBuildMessage` can carry a pre-built `BuildEventArgs`; `LogDeferredMessages` raises it as-is (via `ILoggingService.LogBuildEvent`) so it is recorded under its own event type. `XMake.GetMessagesToLogInBuildLoggers` builds the event in `TryCreateServerLifecycleEvent()`. - **Spawn vs. reuse** is distinguished by a per-build counter in the server process (builds are serialized behind the busy mutex). The "not used" reason/reasonCode is recorded by the client (`MSBuildClientApp`) or by `Main` when a requested server is precluded locally, and paired in a single `ServerNotUsedReason` so the localized text and stable code cannot drift. - New localized resources (with `.xlf` regenerated via `UpdateXlf`). ### Tooling The MSBuild Structured Log Viewer / msbuildlog.com support for the v27 record is in KirillOsenkov/MSBuildStructuredLog#955, which renders the event as a dedicated node. Verified end-to-end: a locally built server MSBuild emits v27 binlogs for the spawned / reused / short-lived / not-used cases, and both a current in-repo reader and the #955 StructuredLogger reconstruct the event with all structured fields. ### Why this is not a breaking change The event is `MessageImportance.Low`, exactly like the sibling `Process` / `CommandLine` / `LongPaths` deferred messages. It only appears in binary logs and at diagnostic verbosity; default output is unchanged and no new warning/error is introduced. A plain (non-server) build emits nothing. The binary-log format bump is additive: existing readers skip the unknown record. ### Testing - **Serialization round-trips:** the binary-log writer/reader round-trip covers `Spawned` (short-lived) and, separately, `NotUsed` (with non-null `Reason`/`ReasonCode`) and `Reused`; a `Framework.UnitTests` test covers the node-packet `WriteToStream`/`CreateFromStream` path. The dedicated record kind (not `Message`) is asserted. - **Deferred-message glue:** a `BinaryLogger_Tests` case logs a `DeferredBuildMessage` backed by the event through `BeginBuild` and reads the typed event back from the binlog. - **End-to-end** `MSBuildServer_Tests`: spawn+reuse logging (matching PIDs), the short-lived `/mt` message, the not-used reason on fall-back, and absence on a plain build. Assertions resolve the exact localized strings from the MSBuild resources to stay locale-independent. - Repo build is clean (0 warnings). --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jul 15, 2026
Open
tknightnd
pushed a commit
to NewDayTechnology/benchmarkdotnet.analyser
that referenced
this pull request
Jul 22, 2026
Updated [Microsoft.Extensions.DependencyInjection](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.DependencyInjection's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 18.7.0 to 18.8.1. <details> <summary>Release notes</summary> _Sourced from [Microsoft.NET.Test.Sdk's releases](https://github.com/microsoft/vstest/releases)._ ## 18.8.1 ## What's Changed * Fix protocol negotiation timeout when STJ reflection is disabled (18.8.1) by @nohwnd in microsoft/vstest#16281 **Full Changelog**: microsoft/vstest@v18.8.0...v18.8.1 ## 18.8.0 ## What's Changed * Migrate from Newtonsoft.Json to System.Text.Json / Jsonite (merge to main) by @nohwnd in microsoft/vstest#15687 - For more detail refer to https://devblogs.microsoft.com/dotnet/vs-test-is-removing-its-newtonsoft-json-dependency/ * Create source-only filter package by @Youssef1313 in microsoft/vstest#15638 * Add ARM64 msdia140.dll support to test platform packages by @nohwnd in microsoft/vstest#15692 * Fix mutex cleanup crash on macOS/Linux by @nohwnd in microsoft/vstest#15684 * Restrict artifact temp directory permissions on Unix by @nohwnd in microsoft/vstest#15729 * Add support for filtering uncategorized tests with TestCategory=None by @Evangelink in microsoft/vstest#15727 * Fix SCI binding failure in DTA hosts (main) by @nohwnd in microsoft/vstest#15724 * Fix HTML logger parallel file collision by @nohwnd in microsoft/vstest#15435 * Improve error message when testhost cannot be found by @nohwnd in microsoft/vstest#16053 * Fix HTML logger exception on invalid XML chars in test display names by @nohwnd in microsoft/vstest#16051 **Full Changelog**: microsoft/vstest@v18.7.0...v18.8.0 Commits viewable in [compare view](microsoft/vstest@v18.7.0...v18.8.1). </details> Updated [MSBuild.StructuredLogger](https://github.com/KirillOsenkov/MSBuildStructuredLog) from 2.3.204 to 2.3.213. <details> <summary>Release notes</summary> _Sourced from [MSBuild.StructuredLogger's releases](https://github.com/KirillOsenkov/MSBuildStructuredLog/releases)._ ## 2.3.213 ## What's Changed * ci: bump AppVeyor macOS image to Sonoma by @KirillOsenkov with @Copilot in KirillOsenkov/MSBuildStructuredLog#940 * Fix empty MSBuild version list when dotnet process exits early by @snechaev in KirillOsenkov/MSBuildStructuredLog#942 * Fix PATH environment handling for macOS application bundles. Fixes #941 by @snechaev in KirillOsenkov/MSBuildStructuredLog#943 * [TracingView] Fix a case where fast mouse drawing cause the position to jump unexpectedly by @yuehuang010 in KirillOsenkov/MSBuildStructuredLog#944 * Preserve search text during rebuild process in Avalonia version by @snechaev in KirillOsenkov/MSBuildStructuredLog#946 * Bump package version and ship net10 by @stan-sz in KirillOsenkov/MSBuildStructuredLog#947 * Don't specify PublicKey on Mac by @KirillOsenkov in KirillOsenkov/MSBuildStructuredLog#948 * Avalonia 12 support by @maxkatz6 in KirillOsenkov/MSBuildStructuredLog#937 * [macOS] Allow to run multiple instances by @snechaev in KirillOsenkov/MSBuildStructuredLog#949 * Add search field to Files tab in Avalonia version by @rolfbjarne in KirillOsenkov/MSBuildStructuredLog#951 * Bump DotUtils SensitiveDataDetector to 1.0.0 by @YuliiaKovalova in KirillOsenkov/MSBuildStructuredLog#953 * Add MSBuild Server lifecycle node support (binlog format v27) by @JanProvaznik in KirillOsenkov/MSBuildStructuredLog#955 ## New Contributors * @KirillOsenkov with @Copilot made their first contribution in KirillOsenkov/MSBuildStructuredLog#940 * @rolfbjarne made their first contribution in KirillOsenkov/MSBuildStructuredLog#951 **Full Changelog**: KirillOsenkov/MSBuildStructuredLog@v2.3.154...v2.3.213 Commits viewable in [compare view](https://github.com/KirillOsenkov/MSBuildStructuredLog/commits/v2.3.213). </details> Updated [NSubstitute](https://github.com/nsubstitute/NSubstitute) from 5.3.0 to 6.0.0. <details> <summary>Release notes</summary> _Sourced from [NSubstitute's releases](https://github.com/nsubstitute/NSubstitute/releases)._ ## 6.0.0 :information_source: No changes from [Release Candidate 1](https://github.com/nsubstitute/NSubstitute/releases/tag/v6.0.0-rc.1). # NSubstitute v6.0.0 From [RC1](https://github.com/nsubstitute/NSubstitute/releases/tag/v6.0.0-rc.1) notes: * [NEW] `ArgMatchers.Matching` predicate matcher as an alternative to `Is(Expression<Predicate<T>>`. (.NET6 and above.) * [UPDATE] Improved support for custom argument matchers. `Arg.Is` now accepts arg matchers. * [UPDATE][BREAKING] Update target frameworks: .NET8, .NET Standard 2.0 * [UPDATE][BREAKING] Remove legacy obsolete API * [UPDATE][BREAKING] Mark as obsolete api CompatArg with pre c# 7.0 support * [UPDATE][BREAKING] Nullability is enabled for public api for .NET 8+ TFMs * [UPDATE] Migrate documentation to [docfx platform](https://github.com/dotnet/docfx) and update samples to NUnit 4 * [NEW] Added NuGet Package README file. ## Full change list * Update target frameworks and other infrastructure changes by @Romfos in nsubstitute/NSubstitute#831 * Remove Google Groups hyperlinks by @304NotModified in nsubstitute/NSubstitute#804 * Improve output for expected argument matchers in nsubstitute/NSubstitute#806 * Mark Substitute.For<T> method as Pure by @Dzliera in nsubstitute/NSubstitute#844 * Move package creating from build.fsproj to github actions by @Romfos in nsubstitute/NSubstitute#838 * Added .NET 9 to test matrix by @Romfos in nsubstitute/NSubstitute#848 * Update dependencies by @Saibamen in nsubstitute/NSubstitute#843 * Migrate documentation to docfx by @Romfos in nsubstitute/NSubstitute#850 * Added test for issue #716 by @rbeurskens in nsubstitute/NSubstitute#846 * feat: add dependabot for this project for minor and patch updates for nuget packages and github actions by @wmundev in nsubstitute/NSubstitute#792 * #853 Fix matching with multiple generic arguments of the same type by @rholek in nsubstitute/NSubstitute#858 * Ability to mock protected methods with and without return value by @Jason31569 in nsubstitute/NSubstitute#845 * Enable nullability for public api by @Romfos in nsubstitute/NSubstitute#856 * Bugfix/async event handlers return instantly by @jmartschinke in nsubstitute/NSubstitute#808 * Fix matching generic calls with AnyType when the generic argument is also a generic argument in return type, out or ref parameter by @JMolenkamp in nsubstitute/NSubstitute#862 * Feature: allow interception of any generic method call when using Arg.AnyType by @JMolenkamp in nsubstitute/NSubstitute#855 * Params arg unit test by @Jason31569 in nsubstitute/NSubstitute#874 * Added exception extensions for ValueTask without return type (rebase) in nsubstitute/NSubstitute#873 * Migrate to slnx by @Romfos in nsubstitute/NSubstitute#882 * Migrate documentation validation from build.fsproj to Roslyn code generator by @Romfos in nsubstitute/NSubstitute#883 * Fix doc links (#884) in nsubstitute/NSubstitute#886 * Add PackageReadmeFile. by @peymanr34 in nsubstitute/NSubstitute#888 * Make public api and tests the same for all TFMs by @Romfos in nsubstitute/NSubstitute#885 * Migrate documentation samples to NUnit4 by @Romfos in nsubstitute/NSubstitute#889 * Run unit tests in Microsoft.Testing.Platform mode by @Romfos in nsubstitute/NSubstitute#896 * Bump actions/checkout from 4 to 5 by @dependabot[bot] in nsubstitute/NSubstitute#902 * Fix typo in return value documentation by @ericmutta in nsubstitute/NSubstitute#903 * Bump actions/setup-dotnet from 4 to 5 by @dependabot[bot] in nsubstitute/NSubstitute#907 * Fix typo in received calls documentation by @ericmutta in nsubstitute/NSubstitute#904 * Simplify github actions to use less jobs by @Romfos in nsubstitute/NSubstitute#911 * Bump actions/upload-artifact from 4 to 5 by @dependabot[bot] in nsubstitute/NSubstitute#916 * Bump NUnit3TestAdapter from 5.0.0 to 5.2.0 by @dependabot[bot] in nsubstitute/NSubstitute#922 ... (truncated) ## 6.0.0-rc.1 # NSubstitute v6.0.0 Release Candidate 1 Due to the large number of changes in this release, we wanted to start with a release candidate to ensure we've correctly captured breaking changes. * [NEW] `ArgMatchers.Matching` predicate matcher as an alternative to `Is(Expression<Predicate<T>>`. (.NET6 and above.) * [UPDATE] Improved support for custom argument matchers. `Arg.Is` now accepts arg matchers. * [UPDATE][BREAKING] Update target frameworks: .NET8, .NET Standard 2.0 * [UPDATE][BREAKING] Remove legacy obsolete API * [UPDATE][BREAKING] Mark as obsolete api CompatArg with pre c# 7.0 support * [UPDATE][BREAKING] Nullability is enabled for public api for .NET 8+ TFMs * [UPDATE] Migrate documentation to [docfx platform](https://github.com/dotnet/docfx) and update samples to NUnit 4 * [NEW] Added NuGet Package README file. ## Full change list * Update target frameworks and other infrastructure changes by @Romfos in nsubstitute/NSubstitute#831 * Remove Google Groups hyperlinks by @304NotModified in nsubstitute/NSubstitute#804 * Improve output for expected argument matchers in nsubstitute/NSubstitute#806 * Mark Substitute.For<T> method as Pure by @Dzliera in nsubstitute/NSubstitute#844 * Move package creating from build.fsproj to github actions by @Romfos in nsubstitute/NSubstitute#838 * Added .NET 9 to test matrix by @Romfos in nsubstitute/NSubstitute#848 * Update dependencies by @Saibamen in nsubstitute/NSubstitute#843 * Migrate documentation to docfx by @Romfos in nsubstitute/NSubstitute#850 * Added test for issue #716 by @rbeurskens in nsubstitute/NSubstitute#846 * feat: add dependabot for this project for minor and patch updates for nuget packages and github actions by @wmundev in nsubstitute/NSubstitute#792 * #853 Fix matching with multiple generic arguments of the same type by @rholek in nsubstitute/NSubstitute#858 * Ability to mock protected methods with and without return value by @Jason31569 in nsubstitute/NSubstitute#845 * Enable nullability for public api by @Romfos in nsubstitute/NSubstitute#856 * Bugfix/async event handlers return instantly by @jmartschinke in nsubstitute/NSubstitute#808 * Fix matching generic calls with AnyType when the generic argument is also a generic argument in return type, out or ref parameter by @JMolenkamp in nsubstitute/NSubstitute#862 * Feature: allow interception of any generic method call when using Arg.AnyType by @JMolenkamp in nsubstitute/NSubstitute#855 * Params arg unit test by @Jason31569 in nsubstitute/NSubstitute#874 * Added exception extensions for ValueTask without return type (rebase) in nsubstitute/NSubstitute#873 * Migrate to slnx by @Romfos in nsubstitute/NSubstitute#882 * Migrate documentation validation from build.fsproj to Roslyn code generator by @Romfos in nsubstitute/NSubstitute#883 * Fix doc links (#884) in nsubstitute/NSubstitute#886 * Add PackageReadmeFile. by @peymanr34 in nsubstitute/NSubstitute#888 * Make public api and tests the same for all TFMs by @Romfos in nsubstitute/NSubstitute#885 * Migrate documentation samples to NUnit4 by @Romfos in nsubstitute/NSubstitute#889 * Run unit tests in Microsoft.Testing.Platform mode by @Romfos in nsubstitute/NSubstitute#896 * Bump actions/checkout from 4 to 5 by @dependabot[bot] in nsubstitute/NSubstitute#902 * Fix typo in return value documentation by @ericmutta in nsubstitute/NSubstitute#903 * Bump actions/setup-dotnet from 4 to 5 by @dependabot[bot] in nsubstitute/NSubstitute#907 * Fix typo in received calls documentation by @ericmutta in nsubstitute/NSubstitute#904 * Simplify github actions to use less jobs by @Romfos in nsubstitute/NSubstitute#911 * Bump actions/upload-artifact from 4 to 5 by @dependabot[bot] in nsubstitute/NSubstitute#916 * Bump NUnit3TestAdapter from 5.0.0 to 5.2.0 by @dependabot[bot] in nsubstitute/NSubstitute#922 * Bump BenchmarkDotNet from 0.15.2 to 0.15.5 by @dependabot[bot] in nsubstitute/NSubstitute#921 * Add .NET 10 to test matrix by @Romfos in nsubstitute/NSubstitute#913 ... (truncated) Commits viewable in [compare view](nsubstitute/NSubstitute@v5.3.0...v6.0.0). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Companion to dotnet/msbuild#14156, which records how each build relates to the MSBuild Server node as a dedicated
MSBuildServerLifecycleEventArgs, serialized under its ownBinaryLogRecordKind.MSBuildServerLifecycle(binary-log format version 27).This teaches the viewer to read and render that record.
Changes
MSBuildServerLifecyclerecord (BuildEventArgsReader+ a vendoredMSBuildServerLifecycleEventArgs).MSBuildServerNodeunder a "MSBuild Server" folder, with a distinct icon (WPFGeneric.xaml+ Avalonia). The node exposesKind(Spawned / Reused / NotUsed),ShortLived,ProcessId,ReasonandReasonCode.LoggersRegisteredrecord (format v26). Without this, opening a v26/v27 binlog reports "Skipped some data unknown to this version of Viewer" for that record; it is now surfaced as an ordinary message.Behavior for the four server scenarios
Kind=SpawnedKind=Reused(same PID)-nr:false(non-/mt)Kind=NotUsed,ReasonCode=node-reuse-disabled/mt -nr:falseKind=Spawned,ShortLived=TrueNotes
MSBuildServerNodeserializes as aMessage(likeTimedMessage/MessageWithLocation) so.buildloground-tripping is unaffected; the dedicated CLR type still drives the distinct icon.