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
11 changes: 7 additions & 4 deletions .vsts-dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions .vsts-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 24 additions & 2 deletions eng/cibuild_bootstrapped_msbuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Param(
[switch] $prepareMachine,
[bool] $buildStage1 = $True,
[bool] $onlyDocChanged = 0,
[switch] $skipTests,
[string] $stage2Properties = "",
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)

Expand Down Expand Up @@ -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
Expand Down
Loading