|
| 1 | +################################################################################# |
| 2 | +# Licensed to the .NET Foundation under one or more agreements. # |
| 3 | +# The .NET Foundation licenses this file to you under the MIT license. # |
| 4 | +# See the LICENSE file in the project root for more information. # |
| 5 | +################################################################################# |
| 6 | + |
| 7 | +# This pipeline builds all packages using the build.proj Pack target with ReferenceType=Package, |
| 8 | +# then publishes the resulting .nupkg and .snupkg files as a single pipeline artifact. |
| 9 | +# |
| 10 | +# It runs: |
| 11 | +# - On pushes to GitHub main and ADO internal/main (batched) |
| 12 | +# - Nightly at 00:00 UTC on both branches |
| 13 | +# |
| 14 | +# On internal/main the strong-name signing key is downloaded and used to sign assemblies during the |
| 15 | +# build. |
| 16 | +# |
| 17 | +# GOTCHA: This pipeline definition is triggered by GitHub _and_ ADO CI. We distinguish the two via |
| 18 | +# branch filters: |
| 19 | +# |
| 20 | +# - Only the GitHub repo has a 'main' branch. |
| 21 | +# - Only the ADO repo has an 'internal/main' branch. |
| 22 | + |
| 23 | +name: $(DayOfYear)$(Rev:rr) |
| 24 | + |
| 25 | +# Do not trigger this pipeline for PRs. |
| 26 | +pr: none |
| 27 | + |
| 28 | +# Trigger on pushes to main and internal/main, batching concurrent commits. |
| 29 | +trigger: |
| 30 | + batch: true |
| 31 | + branches: |
| 32 | + include: |
| 33 | + - main |
| 34 | + - internal/main |
| 35 | + |
| 36 | +# Nightly schedule at 00:00 UTC. |
| 37 | +schedules: |
| 38 | + - cron: '0 0 * * *' |
| 39 | + displayName: Nightly Build |
| 40 | + branches: |
| 41 | + include: |
| 42 | + - main |
| 43 | + - internal/main |
| 44 | + always: true |
| 45 | + |
| 46 | +# Pipeline parameters visible in the Azure DevOps UI. |
| 47 | +parameters: |
| 48 | + |
| 49 | + # The agent image to use for the build. This must exist in both the ADO-1ES-Pool and |
| 50 | + # ADO-CI-1ES-Pool agent pools. |
| 51 | + - name: agentImage |
| 52 | + displayName: Agent Image |
| 53 | + type: string |
| 54 | + default: ADO-UB24 |
| 55 | + values: |
| 56 | + - ADO-UB24 |
| 57 | + - ADO-Win25 |
| 58 | + |
| 59 | + # The build configuration to use, either Debug or Release. |
| 60 | + - name: buildConfiguration |
| 61 | + displayName: Build Configuration |
| 62 | + type: string |
| 63 | + default: Release |
| 64 | + values: |
| 65 | + - Debug |
| 66 | + - Release |
| 67 | + |
| 68 | + # True to enable debug steps and output. |
| 69 | + - name: debug |
| 70 | + displayName: Enable debug output |
| 71 | + type: boolean |
| 72 | + default: false |
| 73 | + |
| 74 | + # The verbosity level of dotnet CLI commands. |
| 75 | + - name: dotnetVerbosity |
| 76 | + displayName: dotnet CLI Verbosity |
| 77 | + type: string |
| 78 | + default: normal |
| 79 | + values: |
| 80 | + - quiet |
| 81 | + - minimal |
| 82 | + - normal |
| 83 | + - detailed |
| 84 | + - diagnostic |
| 85 | + |
| 86 | +variables: |
| 87 | + # Disable codesign validation injection for CI builds. |
| 88 | + # |
| 89 | + # TODO: Should we enable this for internal/main since those builds produce signed assemblies? |
| 90 | + - name: runCodesignValidationInjection |
| 91 | + value: false |
| 92 | + |
| 93 | + # Skip component governance detection for CI builds. |
| 94 | + # |
| 95 | + # TODO: This should never be skipped, should it? |
| 96 | + #- name: skipComponentGovernanceDetection |
| 97 | + # value: true |
| 98 | + |
| 99 | + # Whether this is an internal (ADO) build that should strong-name sign. |
| 100 | + - name: isInternalBuild |
| 101 | + value: ${{ startsWith(variables['Build.SourceBranch'], 'refs/heads/internal/') }} |
| 102 | + |
| 103 | + # Package version suffix for CI builds. |
| 104 | + - name: buildSuffix |
| 105 | + value: ci |
| 106 | + |
| 107 | +jobs: |
| 108 | + - job: pack_all_packages |
| 109 | + displayName: Pack All Packages |
| 110 | + |
| 111 | + pool: |
| 112 | + ${{ if eq(variables.isInternalBuild, 'True') }}: |
| 113 | + name: ADO-1ES-Pool |
| 114 | + ${{ else }}: |
| 115 | + name: ADO-CI-1ES-Pool |
| 116 | + demands: |
| 117 | + - ImageOverride -equals ${{ parameters.agentImage }} |
| 118 | + |
| 119 | + steps: |
| 120 | + |
| 121 | + # Emit environment variables if debug is enabled. |
| 122 | + - ${{ if eq(parameters.debug, true) }}: |
| 123 | + - pwsh: 'Get-ChildItem Env: | Sort-Object Name' |
| 124 | + displayName: '[Debug] Print Environment Variables' |
| 125 | + |
| 126 | + # Install the .NET SDK from global.json. |
| 127 | + - template: /eng/pipelines/steps/install-dotnet.yml@self |
| 128 | + parameters: |
| 129 | + debug: ${{ parameters.debug }} |
| 130 | + |
| 131 | + # Clean any pre-existing .nupkg / .snupkg files from the packages/ directory |
| 132 | + # to ensure we only publish packages produced by this run. |
| 133 | + - pwsh: | |
| 134 | + Write-Host 'Cleaning packages/ directory...' |
| 135 | + Remove-Item -Force "$(Build.SourcesDirectory)/packages/*.nupkg" -ErrorAction SilentlyContinue |
| 136 | + Remove-Item -Force "$(Build.SourcesDirectory)/packages/*.snupkg" -ErrorAction SilentlyContinue |
| 137 | + Write-Host 'Done.' |
| 138 | + displayName: Clean packages/ directory |
| 139 | +
|
| 140 | + # On internal/main, download the strong-name signing key and setup assembly signing. |
| 141 | + - ${{ if eq(variables.isInternalBuild, 'True') }}: |
| 142 | + - task: DownloadSecureFile@1 |
| 143 | + displayName: Download Signing Key |
| 144 | + inputs: |
| 145 | + secureFile: netfxKeypair.snk |
| 146 | + name: keyFile |
| 147 | + |
| 148 | + - pwsh: | |
| 149 | + Write-Host "##vso[task.setvariable variable=signingKeyArg]-p:SigningKeyPath=`"$(keyFile.secureFilePath)`"" |
| 150 | + displayName: Set Signing Key Argument |
| 151 | +
|
| 152 | + # Run the Pack target via build.proj. |
| 153 | + # On internal/main the signing key path is included via $(signingKeyArg). |
| 154 | + - task: DotNetCoreCLI@2 |
| 155 | + displayName: build.proj - Pack (ReferenceType=Package) |
| 156 | + inputs: |
| 157 | + command: build |
| 158 | + projects: '$(Build.SourcesDirectory)/build.proj' |
| 159 | + arguments: >- |
| 160 | + -t:Pack |
| 161 | + -p:Configuration=${{ parameters.buildConfiguration }} |
| 162 | + -p:ReferenceType=Package |
| 163 | + -p:BuildNumber="$(Build.BuildNumber)" |
| 164 | + -p:BuildSuffix=$(buildSuffix) |
| 165 | + $(signingKeyArg) |
| 166 | + -verbosity:${{ parameters.dotnetVerbosity }} |
| 167 | +
|
| 168 | + # List produced packages for diagnostics. |
| 169 | + - pwsh: | |
| 170 | + Write-Host 'Packages produced:' |
| 171 | + Get-ChildItem "$(Build.SourcesDirectory)/packages/*.nupkg" -ErrorAction SilentlyContinue | Format-Table Name, Length |
| 172 | + Get-ChildItem "$(Build.SourcesDirectory)/packages/*.snupkg" -ErrorAction SilentlyContinue | Format-Table Name, Length |
| 173 | + displayName: List produced packages |
| 174 | +
|
| 175 | + # Publish all .nupkg and .snupkg files from packages/ as a pipeline artifact. |
| 176 | + - task: PublishPipelineArtifact@1 |
| 177 | + displayName: Publish NuGet Packages |
| 178 | + inputs: |
| 179 | + targetPath: '$(Build.SourcesDirectory)/packages' |
| 180 | + artifactName: Packages |
| 181 | + publishLocation: pipeline |
0 commit comments