Skip to content

Commit

Permalink
🔨 Enable MSBuild COMM log in bootstrap (#66832)
Browse files Browse the repository at this point in the history
* 🔨 Enable MSBuild COMM log in bootstrap

Fixed a gap where we were calling MSBuild without setting up the COMM
log. This uses a bigger hammer approach by setting the ENV variables at
the YML level.
  • Loading branch information
Jared Parsons authored Feb 13, 2023
1 parent a76d9ca commit f0736b8
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 95 deletions.
23 changes: 22 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ stages:
demands: ImageOverride -equals windows.vs2022preview.amd64.open
timeoutInMinutes: 90
variables:
compilerChange: $[dependencies.Determine_Changes.outputs['SetPathVars_compilers.containsChange']]
- template: eng/pipelines/variables-build.yml
parameters:
configuration: Release
- name: compilerChange
value: $[dependencies.Determine_Changes.outputs['SetPathVars_compilers.containsChange']]
steps:
- template: eng/pipelines/checkout-windows-task.yml

Expand Down Expand Up @@ -261,6 +265,10 @@ stages:
name: NetCore-Public
demands: ImageOverride -equals windows.vs2022preview.amd64.open
timeoutInMinutes: 90
variables:
- template: eng/pipelines/variables-build.yml
parameters:
configuration: Debug
steps:
- template: eng/pipelines/checkout-windows-task.yml

Expand All @@ -279,6 +287,10 @@ stages:
name: NetCore-Public
demands: ImageOverride -equals windows.vs2022preview.amd64.open
timeoutInMinutes: 90
variables:
- template: eng/pipelines/variables-build.yml
parameters:
configuration: Release
steps:
- template: eng/pipelines/checkout-windows-task.yml

Expand Down Expand Up @@ -321,6 +333,10 @@ stages:
name: NetCore-Public
demands: ImageOverride -equals windows.vs2022preview.amd64.open
timeoutInMinutes: 90
variables:
- template: eng/pipelines/variables-build.yml
parameters:
configuration: Release
steps:
- template: eng/pipelines/checkout-windows-task.yml

Expand All @@ -346,6 +362,11 @@ stages:
name: NetCore-Public
demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open
timeoutInMinutes: 35
variables:
- template: eng/pipelines/variables-build.yml
parameters:
configuration: Debug

steps:
- template: eng/pipelines/checkout-unix-task.yml

Expand Down
97 changes: 44 additions & 53 deletions eng/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -261,70 +261,61 @@ function Get-PackageDir([string]$name, [string]$version = "") {
return $p
}

function Run-MSBuild([string]$projectFilePath, [string]$buildArgs = "", [string]$logFileName = "", [switch]$parallel = $true, [switch]$summary = $true, [switch]$warnAsError = $true, [string]$configuration = $script:configuration, [switch]$runAnalyzers = $false) {
# Because we override the C#/VB toolset to build against our LKG package, it is important
# that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
# we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
# MSBuildAdditionalCommandLineArgs=
$args = "/p:TreatWarningsAsErrors=true /nologo /nodeReuse:false /p:Configuration=$configuration ";

if ($warnAsError) {
$args += " /warnaserror"
}
# Create a bootstrap build of the compiler. Returns the directory where the bootstrap build
# is located.
#
# Important to not set $script:bootstrapDir here yet as we're actually in the process of
# building the bootstrap.
function Make-BootstrapBuild([switch]$force32 = $false) {

if ($summary) {
$args += " /consoleloggerparameters:Verbosity=minimal;summary"
} else {
$args += " /consoleloggerparameters:Verbosity=minimal"
}
function Run-MSBuild([string]$projectFilePath, [string]$buildArgs = "", [string]$logFileName = "", [string]$configuration = $script:configuration, [switch]$runAnalyzers = $false) {
# Because we override the C#/VB toolset to build against our LKG package, it is important
# that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
# we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
# MSBuildAdditionalCommandLineArgs=
$args = "/p:TreatWarningsAsErrors=true /nologo /nodeReuse:false /p:Configuration=$configuration ";

if ($parallel) {
$args += " /m"
}
if ($warnAsError) {
$args += " /warnaserror"
}

if ($runAnalyzers) {
$args += " /p:RunAnalyzersDuringBuild=true"
}
if ($runAnalyzers) {
$args += " /p:RunAnalyzersDuringBuild=true"
}

if ($binaryLog) {
if ($logFileName -eq "") {
$logFileName = [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
if ($binaryLog) {
if ($logFileName -eq "") {
$logFileName = [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
}
$logFileName = [IO.Path]::ChangeExtension($logFileName, ".binlog")
$logFilePath = Join-Path $LogDir $logFileName
$args += " /bl:$logFilePath"
}
$logFileName = [IO.Path]::ChangeExtension($logFileName, ".binlog")
$logFilePath = Join-Path $LogDir $logFileName
$args += " /bl:$logFilePath"
}

if ($officialBuildId) {
$args += " /p:OfficialBuildId=" + $officialBuildId
}
if ($officialBuildId) {
$args += " /p:OfficialBuildId=" + $officialBuildId
}

if ($ci) {
$args += " /p:ContinuousIntegrationBuild=true"
# Temporarily disable RestoreUseStaticGraphEvaluation to work around this NuGet issue
# in our CI builds
# https://github.com/NuGet/Home/issues/12373
$args += " /p:RestoreUseStaticGraphEvaluation=false"
}
if ($ci) {
$args += " /p:ContinuousIntegrationBuild=true"
# Temporarily disable RestoreUseStaticGraphEvaluation to work around this NuGet issue
# in our CI builds
# https://github.com/NuGet/Home/issues/12373
$args += " /p:RestoreUseStaticGraphEvaluation=false"
}

if ($bootstrapDir -ne "") {
$args += " /p:BootstrapBuildPath=$bootstrapDir"
}
if ($bootstrapDir -ne "") {
$args += " /p:BootstrapBuildPath=$bootstrapDir"
}

$args += " $buildArgs"
$args += " $projectFilePath"
$args += " $properties"
$args += " $buildArgs"
$args += " $projectFilePath"
$args += " $properties"

$buildTool = InitializeBuildTool
Exec-Console $buildTool.Path "$($buildTool.Command) $args"
}
$buildTool = InitializeBuildTool
Exec-Console $buildTool.Path "$($buildTool.Command) $args"
}

# Create a bootstrap build of the compiler. Returns the directory where the bootstrap build
# is located.
#
# Important to not set $script:bootstrapDir here yet as we're actually in the process of
# building the bootstrap.
function Make-BootstrapBuild([switch]$force32 = $false) {
Write-Host "Building bootstrap compiler"

$dir = Join-Path $ArtifactsDir "Bootstrap"
Expand Down
67 changes: 27 additions & 40 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@ function BuildSolution() {

}

if ($ci) {
${env:ROSLYNCOMMANDLINELOGFILE} = Join-Path $LogDir "Build.Server.log"
${env:MSBUILDDEBUGCOMM} = 1
${env:MSBUILDDEBUGPATH} = Join-Path $LogDir "MSbuild.Comm.log"
}

$projects = Join-Path $RepoRoot $solution
$toolsetBuildProj = InitializeToolset

Expand All @@ -261,40 +255,33 @@ function BuildSolution() {
# https://github.com/NuGet/Home/issues/12373
$restoreUseStaticGraphEvaluation = if ($ci) { $false } else { $true }

try {
MSBuild $toolsetBuildProj `
$bl `
/p:Configuration=$configuration `
/p:Projects=$projects `
/p:RepoRoot=$RepoRoot `
/p:Restore=$restore `
/p:Build=$build `
/p:Rebuild=$rebuild `
/p:Pack=$pack `
/p:Sign=$sign `
/p:Publish=$publish `
/p:ContinuousIntegrationBuild=$ci `
/p:OfficialBuildId=$officialBuildId `
/p:RunAnalyzersDuringBuild=$runAnalyzers `
/p:BootstrapBuildPath=$bootstrapDir `
/p:TreatWarningsAsErrors=$warnAsError `
/p:EnableNgenOptimization=$applyOptimizationData `
/p:IbcOptimizationDataDir=$ibcDir `
/p:RestoreUseStaticGraphEvaluation=$restoreUseStaticGraphEvaluation `
/p:VisualStudioIbcDrop=$ibcDropName `
/p:VisualStudioDropAccessToken=$officialVisualStudioDropAccessToken `
$suppressExtensionDeployment `
$msbuildWarnAsError `
$buildFromSource `
$generateDocumentationFile `
$roslynUseHardLinks `
@properties
}
finally {
${env:ROSLYNCOMMANDLINELOGFILE} = $null
${env:MSBUILDDEBUGCOMM} = 0
${env:MSBUILDDEBUGPATH} = $null
}
MSBuild $toolsetBuildProj `
$bl `
/p:Configuration=$configuration `
/p:Projects=$projects `
/p:RepoRoot=$RepoRoot `
/p:Restore=$restore `
/p:Build=$build `
/p:Rebuild=$rebuild `
/p:Pack=$pack `
/p:Sign=$sign `
/p:Publish=$publish `
/p:ContinuousIntegrationBuild=$ci `
/p:OfficialBuildId=$officialBuildId `
/p:RunAnalyzersDuringBuild=$runAnalyzers `
/p:BootstrapBuildPath=$bootstrapDir `
/p:TreatWarningsAsErrors=$warnAsError `
/p:EnableNgenOptimization=$applyOptimizationData `
/p:IbcOptimizationDataDir=$ibcDir `
/p:RestoreUseStaticGraphEvaluation=$restoreUseStaticGraphEvaluation `
/p:VisualStudioIbcDrop=$ibcDropName `
/p:VisualStudioDropAccessToken=$officialVisualStudioDropAccessToken `
$suppressExtensionDeployment `
$msbuildWarnAsError `
$buildFromSource `
$generateDocumentationFile `
$roslynUseHardLinks `
@properties
}

# Get the branch that produced the IBC data this build is going to consume.
Expand Down
4 changes: 4 additions & 0 deletions eng/pipelines/build-unix-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
${{ if ne(parameters.vmImageName, '') }}:
vmImage: ${{ parameters.vmImageName }}
timeoutInMinutes: 40
variables:
- template: variables-build.yml
parameters:
configuration: ${{ parameters.configuration }}

steps:
- template: checkout-unix-task.yml
Expand Down
6 changes: 5 additions & 1 deletion eng/pipelines/build-windows-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ jobs:
vmImage: ${{ parameters.vmImageName }}
timeoutInMinutes: 40
variables:
artifactName: ${{ parameters.testArtifactName }}
- template: variables-build.yml
parameters:
configuration: ${{ parameters.configuration }}
- name: artifactName
value: ${{ parameters.testArtifactName }}

steps:
- template: checkout-windows-task.yml
Expand Down
15 changes: 15 additions & 0 deletions eng/pipelines/variables-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are common build variables that need to be injected to ensure
# we have diagnostic logs available for investigation

parameters:
- name: configuration
type: string
default: 'Debug'

variables:
- name: ROSLYNCOMMANDLINELOGFILE
value: '$(Build.SourcesDirectory)/artifacts/log/${{ parameters.configuration }}/Build.Server.log'
- name: MSBUILDDEBUGCOMM
value: 1
- name: MSBUILDDEBUGPATH
value: '$(Build.SourcesDirectory)/artifacts/log/${{ parameters.configuration }}/MSBuild.comm.log'

0 comments on commit f0736b8

Please sign in to comment.