Repository navigation
Merge MSBuild functions in tools.ps1/sh - #16916
Conversation
... and remove the InitializeToolset call from the functions by calling the nuget cache export function directly
There was a problem hiding this comment.
Pull request overview
Refactors the MSBuild helper in eng/common/tools.ps1 and eng/common/tools.sh by collapsing the previous MSBuild + MSBuild-Core wrapper pair into a single MSBuild function, dropping the InitializeToolset call that the wrapper used to make, and instead invoking GetNuGetPackageCachePath once at script-load time so the NuGet package cache environment variables are still exported.
Changes:
- Merged
MSBuildandMSBuild-Coreinto a single function in bothtools.ps1andtools.sh, removing theInitializeToolsetcall previously triggered fromMSBuild. - Reordered
tools.ps1soDotNetandEnable-Nuget-EnhancedRetryare now defined alongside the other helpers rather than after the script's bottom initialization block. - Added a top-level
GetNuGetPackageCachePathinvocation at the end of both scripts to ensureNUGET_PACKAGESis still exported even thoughInitializeToolsetis no longer implicitly run byMSBuild.
Show a summary per file
| File | Description |
|---|---|
| eng/common/tools.ps1 | Merges MSBuild/MSBuild-Core, relocates DotNet and Enable-Nuget-EnhancedRetry, and calls GetNuGetPackageCachePath at script-load. |
| eng/common/tools.sh | Merges MSBuild/MSBuild-Core and calls GetNuGetPackageCachePath at script-load. |
Note: eng/common is mirrored from Arcade, so making these changes in dotnet/arcade is correct. The behavioral change to export NUGET_PACKAGES at script source time (rather than lazily on first InitializeToolset call) affects every consumer that sources tools.ps1/tools.sh, including scripts that never invoke MSBuild; this widens blast radius beyond the MSBuild callers.
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
All the env vars removed in this commit are already the default in NuGet, there's no need anymore to set them. The two plugin env vars have a slightly different value but that shouldn't matter (20 vs 30s). The settings is from eight years ago when the default didn't exist. Also rename the GetNuGetPackageCachePath function to InitializeNuGetPackageCachePath to not imply that the function only returns data without side effects. WPF is the only repository that currently uses that function name. I'm gonna update that when it flows to that repo.
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (1)
eng/common/tools.sh:513
- The bash
MSBuildpreviously exportedNUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20andNUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20(andWrite-PipelineSetVariable'd them) whenever running under CI. The merged function no longer does that, and the values are not set anywhere else ineng/common. This is a behavior change that isn't called out in the PR description; if the intent is to drop these, please mention it, otherwise restore them inside the newif [[ "$ci" == true ]]block to keep parity with the previous behavior (and with the PowerShell side once it's also restored).
function MSBuild {
if [[ "$ci" == true ]]; then
if [[ "$binary_log" != true && "$exclude_ci_binary_log" != true ]]; then
Write-PipelineTelemetryError -category 'Build' "Binary log must be enabled in CI build, or explicitly opted-out from with the -noBinaryLog switch."
ExitWithExitCode 1
fi
if [[ "$node_reuse" == true ]]; then
Write-PipelineTelemetryError -category 'Build' "Node reuse must be disabled in CI build."
ExitWithExitCode 1
fi
fi
- Files reviewed: 2/2 changed files
- Comments generated: 1
…translator PR dotnet#16814 removed the Microsoft.DotNet.ArcadeLogging MSBuild logger. That logger is what translated MSBuild error/warning events into Azure DevOps `##vso[task.logissue type=error]` logging commands, which populate a build timeline record's issues[] collection. dotnet-helix-service Build Analysis relies on those timeline issues to detect build/compile failures; without the logger, command-line `build.cmd` compile errors are written only to the console summary and binlog, so Build Analysis sees a failed step with no issues, drops it, and reports the build green. This restores the logger, but pared down to just that job. Per the original issue (dotnet#16794), the `NETCORE_ENGINEERING_TELEMETRY=<Category>` markers were the main complaint -- they add noise to CI logs. So this does NOT bring the markers back: - PipelinesLogger is reduced to translating errors and warnings into `logissue` timeline commands (type/sourcepath/line/column/code/message). - All telemetry-category plumbing is left removed: the marker prefix, the TelemetryLogged/project category tracking, the `_NETCORE_ENGINEERING_TELEMETRY` global properties in the SDK toolset .proj files, the Helix SDK category telemetry, the `(NETCORE_ENGINEERING_TELEMETRY=...)` marker in Write-PipelineTelemetryError, and the telemetry docs. Logger re-wired into the merged MSBuild function in eng/common/tools.ps1 and tools.sh (functions were merged in dotnet#16916); build.sh keeps current CI node_reuse handling and re-enables pipelines_log in CI. Co-authored-by: Copilot <[email protected]>
- Derive the ArcadeLogging.dll toolset subfolder ('net' vs 'netframework')
from the build tool command instead of \\.Framework\, which no
longer exists after the MSBuild-function merge (dotnet#16916) and evaluated to
\, breaking Join-Path when pipelinesLog was enabled.
- Check the logger assembly actually exists (Test-Path / -f) instead of the
always-true non-empty-string check, so a missing logger fails fast with an
actionable message.
- Inline the message formatting into PipelinesLogger and delete MessageBuilder.cs
(per review): the state-machine builder was overkill for the minimal logger
and carried unused usings that would trip TreatWarningsAsErrors.
- Fix comment typos in tools.ps1/tools.sh ('opt-opt' -> 'opt-in',
'while validate' -> 'while validating').
Co-authored-by: Copilot <[email protected]>
... and remove the InitializeToolset call from the functions by calling the nuget cache export function directly.
The
GetNuGetPackageCachePathfunction all doesn't need a IF CI condition as the function is also unconditionally called in eng/common/build.ps1/sh.The
MSBuild-Corefunction is not used by anyone aside from the entry point in the VMR which I will update with the next re-bootstrap (just remove the-Corepart from the function call).Also remove a set of env vars that are already the default in NuGet now.
To double check: