Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ $arguments += " /clp:ForceNoAlign"
# The later changes are ignored when using the cache.
$env:DOTNETSDK_ALLOW_TARGETING_PACK_CACHING=0

# Set up the directory for MSBuild debug logs, so that if MSBuild crashes (MSB4166)
# the failure.txt diagnostics are written to a known location under artifacts/log
# where they'll be captured as build artifacts.
$msbuildDebugLogsDir = "$PSScriptRoot/../artifacts/log/$((Get-Culture).TextInfo.ToTitleCase($configuration[0]))/MsbuildDebugLogs"
New-Item -ItemType Directory -Force -Path $msbuildDebugLogsDir | Out-Null
$env:MSBUILDDEBUGPATH = $msbuildDebugLogsDir
Write-Host "MSBUILDDEBUGPATH=$msbuildDebugLogsDir"

if ($bootstrap -eq $True) {

if ($actionPassedIn) {
Expand Down Expand Up @@ -434,7 +442,15 @@ if ($bootstrap -eq $True) {
$failedBuilds = @()

foreach ($config in $configuration) {
$argumentsWithConfig = $arguments + " -configuration $((Get-Culture).TextInfo.ToTitleCase($config))";
$titleCaseConfig = $((Get-Culture).TextInfo.ToTitleCase($config))

# Update MSBuild debug logs directory for this configuration.
$msbuildDebugLogsDir = "$PSScriptRoot/../artifacts/log/$titleCaseConfig/MsbuildDebugLogs"
New-Item -ItemType Directory -Force -Path $msbuildDebugLogsDir | Out-Null
$env:MSBUILDDEBUGPATH = $msbuildDebugLogsDir
Write-Host "MSBUILDDEBUGPATH=$msbuildDebugLogsDir"
Comment on lines +445 to +451
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

In the multi-configuration loop you update $env:MSBUILDDEBUGPATH per config, but MSBuild node reuse is enabled by default for non-CI runs (/nr:true via eng/common/tools.ps1 where nodeReuse defaults to !$ci). Reused nodes won’t see the updated environment variable, so crash diagnostics may still be written to the previous configuration’s directory, making the per-config directory update potentially misleading. Consider either keeping a single MSBUILDDEBUGPATH for the whole build.ps1 invocation, or disabling node reuse when switching configurations so each config reliably writes to its intended directory.

See below for a potential fix:

# Use a single MSBuild debug logs directory for the entire invocation because
# reused MSBuild nodes do not observe environment variable updates made between
# configurations.
$msbuildDebugLogsDir = "$PSScriptRoot/../artifacts/log/MsbuildDebugLogs"
New-Item -ItemType Directory -Force -Path $msbuildDebugLogsDir | Out-Null
$env:MSBUILDDEBUGPATH = $msbuildDebugLogsDir
Write-Host "MSBUILDDEBUGPATH=$msbuildDebugLogsDir"

foreach ($config in $configuration) {
  $titleCaseConfig = $((Get-Culture).TextInfo.ToTitleCase($config))

Copilot uses AI. Check for mistakes.

$argumentsWithConfig= $arguments + " -configuration $titleCaseConfig";
foreach ($singleArch in $arch) {
$argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig
Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $argumentsWithArch"
Expand Down
8 changes: 8 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@ cmakeargs="${cmakeargs// /%20}"
arguments+=("/p:TargetArchitecture=$arch" "/p:BuildArchitecture=$hostArch")
arguments+=("/p:CMakeArgs=\"$cmakeargs\"" ${extraargs[@]+"${extraargs[@]}"})

# Set up the directory for MSBuild debug logs, so that if MSBuild crashes (MSB4166)
# the failure.txt diagnostics are written to a known location under artifacts/log
# where they'll be captured as build artifacts.
MSBUILDDEBUGPATH="$scriptroot/../artifacts/log/${bootstrapConfig:-Debug}/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.

Why does this use ${bootstrapConfig:-Debug} ? I would expect it to use actual config for non-bootstrap builds.

mkdir -p "$MSBUILDDEBUGPATH"
export MSBUILDDEBUGPATH
echo "MSBUILDDEBUGPATH=$MSBUILDDEBUGPATH"

if [[ "$bootstrap" == "1" ]]; then
# Strip build actions other than -restore and -build from the arguments for the bootstrap build.
bootstrapArguments=()
Expand Down
Loading