Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔨 Enable MSBuild COMM log in bootstrap #66832

Merged
merged 16 commits into from
Feb 13, 2023
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) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is only ever used by the Make-BootstrapBuild function so made it a local function to remove confusion around it. Allowed me to delete several parameter's that weren't being used.

# 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:
ROSLYNCOMMANDLINELOGFILE: '$(Build.SourcesDirectory)/artifacts/log/${{ parameters.configuration }}/Build.Server.log'
MSBUILDDEBUGCOMM: 1
MSBUILDDEBUGPATH: '$(Build.SourcesDirectory)/artifacts/log/${{ parameters.configuration }}/MSBuild.comm.log'

steps:
- template: checkout-unix-task.yml
Expand Down
3 changes: 3 additions & 0 deletions eng/pipelines/build-windows-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
timeoutInMinutes: 40
variables:
artifactName: ${{ parameters.testArtifactName }}
ROSLYNCOMMANDLINELOGFILE: '$(Build.SourcesDirectory)/artifacts/log/${{ parameters.configuration }}/Build.Server.log'
jaredpar marked this conversation as resolved.
Show resolved Hide resolved
MSBUILDDEBUGCOMM: 1
MSBUILDDEBUGPATH: '$(Build.SourcesDirectory)/artifacts/log/${{ parameters.configuration }}/MSBuild.comm.log'

steps:
- template: checkout-windows-task.yml
Expand Down