Skip to content

Set MSBUILDDEBUGPATH in common build scripts for crash diagnostics#16715

Merged
danmoseley merged 1 commit intodotnet:mainfrom
danmoseley:arcade-msbuilddebugpath
Apr 14, 2026
Merged

Set MSBUILDDEBUGPATH in common build scripts for crash diagnostics#16715
danmoseley merged 1 commit intodotnet:mainfrom
danmoseley:arcade-msbuilddebugpath

Conversation

@danmoseley
Copy link
Copy Markdown
Member

@danmoseley danmoseley commented Apr 14, 2026

When MSBuild encounters a fatal internal error (MSB4166), it writes a failure.txt crash dump file. By default these go to the system temp directory, which CI pipelines typically don't collect as artifacts — making it hard to diagnose intermittent MSBuild crashes in CI.

This change sets MSBUILDDEBUGPATH in arcade's common build scripts (tools.sh and tools.ps1) to direct these crash diagnostics to artifacts/log/<configuration>/MsbuildDebugLogs/, which is already collected by CI pipelines.

Key design choices:

  • Guarded: only sets MSBUILDDEBUGPATH if it isn't already defined, so repo-specific or user overrides are respected
  • No explicit mkdir: MSBuild's FrameworkDebugUtils.SetDebugPath() creates the directory itself inside a try/catch when needed, avoiding set -e risk in bash and keeping the change minimal
  • No disk bloat: without MSBUILDDEBUGENGINE=1, only crash dump files are written here (not verbose debug/scheduler logs), so the directory will be empty on healthy builds
  • Unconditional (not CI-only): crash diagnostics are useful for local debugging too, and since only crash files land here, there's no performance or disk concern

Several repos (e.g., dotnet/runtime) already set MSBUILDDEBUGPATH in their own build scripts for specific subcomponents. This change provides the default for all arcade-based repos, filling the gap for top-level builds.

Relates to getting data to fix dotnet/runtime#92290 and any other MSBuild crashes in any arcade repos
Supersedes dotnet/runtime#126806

Set MSBUILDDEBUGPATH in eng/common/tools.sh and eng/common/tools.ps1 so that
MSBuild crash diagnostics (MSB4166 failure.txt files) are written to a known
location under artifacts/log/<config>/MsbuildDebugLogs/ instead of the system
temp directory. This ensures they are captured as build artifacts in CI.

Previously individual repos had to set this in their own build scripts (e.g.
dotnet/runtime's src/coreclr/build-runtime.sh, src/tests/build.sh). Putting
it in the common tooling covers all repos using arcade infrastructure.

Relates to dotnet/runtime#92290

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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 improves MSBuild crash diagnostics collection by defaulting MSBUILDDEBUGPATH in Arcade’s shared build tooling to a location under artifacts/log/<configuration>/, which CI already publishes as an artifact—making MSB4166 “failure.txt” outputs available for postmortem analysis.

Changes:

  • Set MSBUILDDEBUGPATH (only if not already defined) in eng/common/tools.sh.
  • Set MSBUILDDEBUGPATH (only if not already defined) in eng/common/tools.ps1.
  • Route MSBuild crash diagnostics to artifacts/log/<configuration>/MsbuildDebugLogs/.
Show a summary per file
File Description
eng/common/tools.sh Exports MSBUILDDEBUGPATH to a stable artifacts log subdirectory when unset.
eng/common/tools.ps1 Sets $env:MSBUILDDEBUGPATH to a stable artifacts log subdirectory when unset.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@danmoseley danmoseley requested a review from hoyosjs April 14, 2026 15:03
Comment thread eng/common/tools.ps1
# Direct MSBuild crash diagnostics (MSB4166 failure.txt files) to a known location
# under artifacts/log so they are captured as build artifacts in CI.
if (-not $env:MSBUILDDEBUGPATH) {
$env:MSBUILDDEBUGPATH = Join-Path $LogDir 'MsbuildDebugLogs'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This also collects them on dev machines - I am not against that anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes and I think that's a good thing.

@danmoseley danmoseley merged commit 0c66f15 into dotnet:main Apr 14, 2026
13 checks passed
@danmoseley danmoseley deleted the arcade-msbuilddebugpath branch April 14, 2026 23:45
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.

MSBuild crashing in the build

3 participants