diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 728951d356999..ff79d9eda4f12 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1 index 6d56827978aa2..15121ddd13fac 100644 --- a/eng/build-utils.ps1 +++ b/eng/build-utils.ps1 @@ -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" diff --git a/eng/build.ps1 b/eng/build.ps1 index c674b0b41f34f..116347143d538 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -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 @@ -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. diff --git a/eng/pipelines/build-unix-job.yml b/eng/pipelines/build-unix-job.yml index f1304b25680da..20bbe8f070684 100644 --- a/eng/pipelines/build-unix-job.yml +++ b/eng/pipelines/build-unix-job.yml @@ -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 diff --git a/eng/pipelines/build-windows-job.yml b/eng/pipelines/build-windows-job.yml index 22108cb5b0671..606ec1c431bbf 100644 --- a/eng/pipelines/build-windows-job.yml +++ b/eng/pipelines/build-windows-job.yml @@ -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 diff --git a/eng/pipelines/variables-build.yml b/eng/pipelines/variables-build.yml new file mode 100644 index 0000000000000..2890518d59a58 --- /dev/null +++ b/eng/pipelines/variables-build.yml @@ -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'