Skip to content
Merged
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
199 changes: 95 additions & 104 deletions eng/pipelines/templates/jobs/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ parameters:
- name: sign
displayName: True when build output should be signed (includes dry runs)
type: boolean
default: true
default: false

# Overrides the rid that is produced by the build.
- name: targetRid
Expand Down Expand Up @@ -133,13 +133,6 @@ jobs:
image: ${{ parameters.container.image }}
options: $(defaultContainerOptions)

# Currently, CodeQL slows the build down too much
# https://github.com/dotnet/source-build/issues/4276
${{ if and(parameters.isBuiltFromVmr, startswith(parameters.buildName, 'Windows'), eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}:
timeoutInMinutes: 720
${{ else }}:
timeoutInMinutes: 240

${{ if ne(parameters.reuseBuildArtifactsFrom, '') }}:
${{ if eq(parameters.buildPass, '') }}:
# For PR builds, skip the stage 2 build if the stage 1 build fails.
Expand Down Expand Up @@ -201,56 +194,92 @@ jobs:
# Build up the command line variables. We avoid doing this in the script sections below
# because AzDO will not echo command lines if they are more than a single line.

## Build command line - Windows
- ${{ if eq(parameters.targetOS, 'windows') }}:
## Basic arguments
- name: baseArguments
value: -ci -cleanWhileBuilding -prepareMachine -c ${{ parameters.configuration }} $(officialBuildParameter) /p:VerticalName=$(Agent.JobName) /p:ArtifactsStagingDir=$(artifactsStagingDir)
## Build command line
Copy link
Member Author

Choose a reason for hiding this comment

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

I made the build command args/props available to all OS platforms so that the mac & linux legs could use the signing args + props.


### Command line prefix
- name: commandPrefix
${{ if eq(parameters.targetOS, 'windows') }}:
value: '-'
${{ else }}:
value: '--'

### Basic arguments
- name: cleanArgument
${{ if eq(parameters.targetOS, 'windows') }}:
value: cleanWhileBuilding
${{ else }}:
value: clean-while-building

- name: baseArguments
value: $(commandPrefix)ci $(commandPrefix)$(cleanArgument) $(commandPrefix)prepareMachine -c ${{ parameters.configuration }}

- name: baseProperties
value: $(officialBuildParameter) /p:VerticalName=$(Agent.JobName) /p:ArtifactsStagingDir=$(artifactsStagingDir)

- name: targetArguments
- name: targetProperties
${{ if and(ne(parameters.targetOS, ''), ne(parameters.targetArchitecture, '')) }}:
value: /p:TargetOS=${{ parameters.targetOS }} /p:TargetArchitecture=${{ parameters.targetArchitecture }}
${{ elseif ne(parameters.targetOS, '') }}:
value: /p:TargetOS=${{ parameters.targetOS }}
${{ else }}:
value: /p:TargetArchitecture=${{ parameters.targetArchitecture }}

### Signing variables
- ${{ if eq(parameters.sign, 'True') }}:
- name: _SignDiagnosticFilesArgs
### Signing
- name: _SignDiagnosticFilesArgs
value: ''
- ${{ if eq(parameters.sign, 'True') }}:
- name: signArguments
value: $(commandPrefix)sign
- ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
# The _SignType variable is used by microbuild installation
- name: _SignType
value: ''
- ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
# The _SignType variable is used by microbuild installation
- name: _SignType
value: ''
- name: signArguments
value: -sign /p:ForceDryRunSigning=true
- ${{ else }}:
- name: _SignType
value: real
- name: signArguments
value: -sign /p:DotNetSignType=real /p:TeamName=$(_TeamName)
- name: _EnableDacSigning
${{ if and(eq(parameters.isBuiltFromVmr, true), ne(parameters.buildSourceOnly, 'True')) }}:
value: true
${{ else }}:
value: false
- name: signProperties
value: /p:ForceDryRunSigning=true
- ${{ else }}:
- name: signArguments
value: ''
- name: _SignDiagnosticFilesArgs
value: ''
- name: _SignType
value: real
- name: signProperties
value: /p:DotNetSignType=real /p:TeamName=$(_TeamName)
- name: _EnableDacSigning
${{ if and(eq(parameters.isBuiltFromVmr, true), ne(parameters.buildSourceOnly, 'True')) }}:
value: true
${{ else }}:
value: false
- ${{ else }}:
- name: signArguments
value: ''
- name: signProperties
value: ''
- name: _SignType
value: ''

### Build Pass
- ${{ if ne(parameters.buildPass, '') }}:
- name: buildPassProperties
value: /p:DotNetBuildPass=${{ parameters.buildPass }}
- ${{ else }}:
- name: buildPassProperties
value: ''

### Build Pass
- ${{ if ne(parameters.buildPass, '') }}:
- name: buildPassArguments
value: /p:DotNetBuildPass=${{ parameters.buildPass }}
- ${{ else }}:
- name: buildPassArguments
value: ''
### Additional properties
- ${{ if eq(parameters.enableIBCOptimization, 'true') }}:
- name: ibcProperties
value: '/p:EnableIBCOptimization=true /p:IBCDropAccessToken=$(dn-bot-devdiv-drop-r-code-r)'
- ${{ else }}:
- name: ibcProperties
value: ''

### Additional arguments
- ${{ if eq(parameters.enableIBCOptimization, 'true') }}:
- name: ibcArguments
value: '/p:EnableIBCOptimization=true /p:IBCDropAccessToken=$(dn-bot-devdiv-drop-r-code-r)'
- ${{ else }}:
- name: ibcArguments
value: ''
# Timeout
Copy link
Member Author

@ellahathaway ellahathaway Mar 25, 2025

Choose a reason for hiding this comment

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

I moved the timeout logic here so that the timeout could be conditionally set based on the value of _SignType

## Real signing takes a while - increase the timeout to allow for that
${{ if eq(variables['_SignType'], 'real') }}:
timeoutInMinutes: 720
## Currently, CodeQL slows the build down too much
## https://github.com/dotnet/source-build/issues/4276
${{ elseif and(parameters.isBuiltFromVmr, startswith(parameters.buildName, 'Windows'), eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}:
timeoutInMinutes: 720
${{ else }}:
timeoutInMinutes: 240

templateContext:
outputParentDirectory: $(Build.ArtifactStagingDirectory)
Expand Down Expand Up @@ -402,10 +431,12 @@ jobs:

- script: build.cmd
$(baseArguments)
$(targetArguments)
$(signArguments)
$(buildPassArguments)
$(ibcArguments)
$(baseProperties)
$(targetProperties)
$(signProperties)
$(buildPassProperties)
$(ibcProperties)
$(_SignDiagnosticFilesArgs)
${{ parameters.extraProperties }}
displayName: Build
Expand All @@ -421,8 +452,8 @@ jobs:
- ${{ if eq(parameters.runTests, 'True') }}:
- script: build.cmd
$(baseArguments)
$(targetArguments)
$(buildPassArguments)
$(targetProperties)
$(buildPassProperties)
${{ parameters.extraProperties }}
-test
-excludeCIBinarylog
Expand Down Expand Up @@ -476,7 +507,8 @@ jobs:

customEnvVars=""
customPreBuildArgs=""
customBuildArgs="--ci --clean-while-building --prepareMachine -c ${{ parameters.configuration }} $(officialBuildParameter)"
customBuildArgs="$(baseArguments) $(signArguments) $(_SignDiagnosticFilesArgs)"
extraBuildProperties="$(baseProperties) $(targetProperties) $(signProperties) $(buildPassProperties) ${{ parameters.extraProperties }}"

if [[ '${{ parameters.runOnline }}' == 'True' ]]; then
customBuildArgs="$customBuildArgs --online"
Expand All @@ -502,16 +534,6 @@ jobs:
customBuildArgs="$customBuildArgs --use-mono-runtime"
fi

if [[ '${{ parameters.sign }}' == 'True' ]] && [[ '${{ parameters.buildSourceOnly }}' != 'True' ]]; then
customBuildArgs="$customBuildArgs --sign"
if [[ '$(_SignType)' == 'real' ]] || [[ '$(_SignType)' == 'test' ]]; then
# Force dry run signing until https://github.com/dotnet/source-build/issues/4793 is resolved - https://github.com/dotnet/source-build/issues/4678
extraBuildProperties="$extraBuildProperties /p:DotNetSignType=$(_SignType) /p:TeamName=$(_TeamName) /p:ForceDryRunSigning=true"
else
extraBuildProperties="$extraBuildProperties /p:ForceDryRunSigning=true"
fi
fi

if [[ -n "${{ parameters.targetRid }}" ]]; then
customBuildArgs="$customBuildArgs --target-rid ${{ parameters.targetRid }}"
fi
Expand All @@ -523,26 +545,8 @@ jobs:
fi
fi

if [[ ! -z '${{ parameters.targetOS }}' ]]; then
extraBuildProperties="$extraBuildProperties /p:TargetOS=${{ parameters.targetOS }}"
fi

if [[ ! -z '${{ parameters.targetArchitecture }}' ]]; then
extraBuildProperties="$extraBuildProperties /p:TargetArchitecture=${{ parameters.targetArchitecture }}"
fi

if [[ -n "${{ parameters.buildPass }}" ]]; then
extraBuildProperties="$extraBuildProperties /p:DotNetBuildPass=${{ parameters.buildPass }}"
fi

if [[ -n "${{ parameters.extraProperties }}" ]]; then
extraBuildProperties="$extraBuildProperties ${{ parameters.extraProperties }}"
fi

extraBuildProperties="$extraBuildProperties /p:VerticalName=$(Agent.JobName)"
extraBuildProperties="$extraBuildProperties /p:ArtifactsStagingDir=$(artifactsStagingDir)"

buildArgs="$(additionalBuildArgs) $customBuildArgs $extraBuildProperties"
buildArgs=$(echo $buildArgs | xargs) # Remove extra spaces

for envVar in $customEnvVars; do
customEnvVarsWithBashSyntax="$customEnvVarsWithBashSyntax export $envVar;"
Expand Down Expand Up @@ -580,22 +584,13 @@ jobs:
set -ex

customPreBuildArgs=''
customBuildArgs=''
extraBuildProperties=''
customBuildArgs="--ci --prepareMachine -c ${{ parameters.configuration }} $(officialBuildParameter)"
customBuildArgs="--test --excludeCIBinarylog /bl:artifacts/log/Release/Test.binlog $(baseArguments)"
extraBuildProperties="$(baseProperties) $(targetProperties) ${{ parameters.extraProperties }}"

if [[ '${{ parameters.runOnline }}' == 'False' ]]; then
customPreBuildArgs="$customPreBuildArgs sudo"
fi

if [[ ! -z '${{ parameters.targetOS }}' ]]; then
extraBuildProperties="$extraBuildProperties /p:TargetOS=${{ parameters.targetOS }}"
fi

if [[ ! -z '${{ parameters.targetArchitecture }}' ]]; then
extraBuildProperties="$extraBuildProperties /p:TargetArchitecture=${{ parameters.targetArchitecture }}"
fi

if [[ '${{ parameters.buildSourceOnly }}' == 'True' ]]; then
if [[ '${{ parameters.enablePoison }}' == 'True' ]]; then
customBuildArgs="$customBuildArgs --poison"
Expand All @@ -607,15 +602,11 @@ jobs:
customBuildArgs="$customBuildArgs --target-rid ${{ parameters.targetRid }}"
fi

extraBuildProperties="$extraBuildProperties /p:VerticalName=$(Agent.JobName)"
extraBuildProperties="$extraBuildProperties /p:ArtifactsStagingDir=$(artifactsStagingDir)"

if [[ -n "${{ parameters.extraProperties }}" ]]; then
extraBuildProperties="$extraBuildProperties ${{ parameters.extraProperties }}"
fi
buildArgs="$(additionalBuildArgs) $customBuildArgs $extraBuildProperties"
buildArgs=$(echo $buildArgs | xargs) # Remove extra spaces

cd $(sourcesPath)
$customPreBuildArgs ./build.sh --test --excludeCIBinarylog /bl:artifacts/log/Release/Test.binlog $customBuildArgs $extraBuildProperties $(additionalBuildArgs)
$customPreBuildArgs ./build.sh $buildArgs

displayName: Run Tests
timeoutInMinutes: ${{ variables.runTestsTimeout }}
Expand Down
Loading