diff --git a/.vsts-dotnet-ci.yml b/.vsts-dotnet-ci.yml index b6236fbc1ec..518e53c89a3 100644 --- a/.vsts-dotnet-ci.yml +++ b/.vsts-dotnet-ci.yml @@ -98,7 +98,7 @@ jobs: displayName: cibuild_bootstrapped_msbuild.cmd inputs: filename: 'eng/cibuild_bootstrapped_msbuild.cmd' - arguments: -onlyDocChanged $(onlyDocChanged) + arguments: '-onlyDocChanged $(onlyDocChanged) -stage2Properties /mt' env: ForceUseXCopyMSBuild: 1 # Task to collect code coverage on Windows. Disabled by default due to being unstable and sometimes it stucks forever @@ -210,7 +210,7 @@ jobs: displayName: cibuild_bootstrapped_msbuild.cmd inputs: filename: 'eng/cibuild_bootstrapped_msbuild.cmd' - arguments: '-msbuildEngine dotnet -onlyDocChanged $(onlyDocChanged)' + arguments: '-msbuildEngine dotnet -onlyDocChanged $(onlyDocChanged) -stage2Properties /mt' env: MSBUILDUSESERVER: "1" # Task to collect code coverage on Windows. Disabled by default due to being unstable and sometimes it stucks forever @@ -267,6 +267,9 @@ jobs: continueOnError: true condition: eq(variables.onlyDocChanged, 0) +# Dedicated /mt validation that turns on the ThreadSafeTaskAnalyzer (BuildAnalyzer=true), +# kept as a separate Linux Core job because the analyzer is more expensive and the regular +# bootstrapped CI jobs (which all run /mt now too) do not need it. - job: BootstrapMSBuildWithMTMode displayName: "Linux Core Multithreaded Mode" pool: @@ -406,7 +409,7 @@ jobs: Token: $(dn-bot-dnceng-artifact-feeds-rw) - bash: sudo apt-get update - bash: sudo apt-get install -y libxml2 - - bash: . 'eng/cibuild_bootstrapped_msbuild.sh' --onlyDocChanged $(onlyDocChanged) + - bash: . 'eng/cibuild_bootstrapped_msbuild.sh' --onlyDocChanged $(onlyDocChanged) --stage2Properties '/mt' displayName: CI Build env: MSBUILDUSESERVER: "1" @@ -494,7 +497,7 @@ jobs: arguments: $(Build.SourcesDirectory)/NuGet.config $Token env: Token: $(dn-bot-dnceng-artifact-feeds-rw) - - bash: . 'eng/cibuild_bootstrapped_msbuild.sh' --onlyDocChanged $(onlyDocChanged) + - bash: . 'eng/cibuild_bootstrapped_msbuild.sh' --onlyDocChanged $(onlyDocChanged) --stage2Properties '/mt' displayName: CI Build env: MSBUILDUSESERVER: "1" diff --git a/.vsts-dotnet.yml b/.vsts-dotnet.yml index 971723d8e9e..a5cf5f88edd 100644 --- a/.vsts-dotnet.yml +++ b/.vsts-dotnet.yml @@ -130,6 +130,7 @@ extends: enableComponentGovernance: true signTypeParameter: ${{ parameters.signTypeParameter }} enableOptProf: ${{ parameters.enableOptProf }} + additionalBuildArgs: '/mt' - template: /eng/common/templates-official/post-build/post-build.yml@self parameters: diff --git a/eng/cibuild_bootstrapped_msbuild.ps1 b/eng/cibuild_bootstrapped_msbuild.ps1 index a61ecbe7d4a..ed290aec5cf 100644 --- a/eng/cibuild_bootstrapped_msbuild.ps1 +++ b/eng/cibuild_bootstrapped_msbuild.ps1 @@ -5,6 +5,8 @@ Param( [switch] $prepareMachine, [bool] $buildStage1 = $True, [bool] $onlyDocChanged = 0, + [switch] $skipTests, + [string] $stage2Properties = "", [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties ) @@ -117,14 +119,34 @@ try { # Opt into performance logging. https://github.com/dotnet/msbuild/issues/5900 $env:DOTNET_PERFLOG_DIR=$PerfLogDir + # Mirrors cibuild_bootstrapped_msbuild.sh:96. Required so the apphost-based child task host + # (NodeProviderOutOfProcTaskHost.ResolveAppHostOrFallback) can locate the runtime when the + # parent MSBuild is launched as `dotnet exec MSBuild.dll` (which, unlike the SDK CLI + # `dotnet msbuild`, does not set DOTNET_HOST_PATH automatically). Trying to switch the + # invocation to `dotnet msbuild` here would be cleaner but the SDK CLI's argument + # translation mangles `/mt` into `/m` + `t`, so we keep the explicit `MSBuild.dll` path + # and set DOTNET_HOST_PATH ourselves. + $env:DOTNET_HOST_PATH=$dotnetExePath + # When using bootstrapped MSBuild: # - Turn off node reuse (so that bootstrapped MSBuild processes don't stay running and lock files) # - Create bootstrap environment as it's required when also running tests + # - $stage2Properties are appended to the stage 2 build only (matching cibuild_bootstrapped_msbuild.sh). + # Use this for switches like /mt that should not be passed to the stable MSBuild used in stage 1 + # until a stable version of MT is available in the images. + # Branches mirror cibuild_bootstrapped_msbuild.sh exactly: + # onlyDocChanged=1 → bootstrap not created (artifacts not needed downstream) + # skipTests → bootstrap IS created (downstream MAY consume it), tests omitted + # default → bootstrap created, tests run + $stage2Args = if ($stage2Properties) { $stage2Properties -split '\s+' | Where-Object { $_ } } else { @() } if ($onlyDocChanged) { - & $PSScriptRoot\Common\Build.ps1 -restore -build -ci /p:CreateBootstrap=false /nr:false @properties + & $PSScriptRoot\Common\Build.ps1 -restore -build -ci /p:CreateBootstrap=false /nr:false @properties @stage2Args + } + elseif ($skipTests) { + & $PSScriptRoot\Common\Build.ps1 -restore -build -ci /nr:false @properties @stage2Args } else { - & $PSScriptRoot\Common\Build.ps1 -restore -build -test -ci /nr:false @properties + & $PSScriptRoot\Common\Build.ps1 -restore -build -test -ci /nr:false @properties @stage2Args } exit $lastExitCode