|
| 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 | + # Whether this is an internal (ADO.Net project) or public (Public project) build. |
| 88 | + - name: isInternalBuild |
| 89 | + value: ${{ eq(variables['System.TeamProject'], 'ADO.Net') }} |
| 90 | + |
| 91 | + # Signing key argument passed to build.proj. On internal builds this references the secure file |
| 92 | + # downloaded by DownloadSecureFile@1; on public builds it expands to empty. |
| 93 | + - name: signingKeyArg |
| 94 | + ${{ if eq(variables.isInternalBuild, true) }}: |
| 95 | + value: '-p:SigningKeyPath="$(keyFile.secureFilePath)"' |
| 96 | + ${{ else }}: |
| 97 | + value: '' |
| 98 | + |
| 99 | +jobs: |
| 100 | + - job: pack_all_packages |
| 101 | + displayName: Pack All Packages |
| 102 | + |
| 103 | + pool: |
| 104 | + ${{ if eq(variables.isInternalBuild, true) }}: |
| 105 | + name: ADO-1ES-Pool |
| 106 | + ${{ else }}: |
| 107 | + name: ADO-CI-1ES-Pool |
| 108 | + demands: |
| 109 | + - ImageOverride -equals ${{ parameters.agentImage }} |
| 110 | + |
| 111 | + steps: |
| 112 | + |
| 113 | + # Emit environment variables if debug is enabled. |
| 114 | + - ${{ if eq(parameters.debug, true) }}: |
| 115 | + - pwsh: | |
| 116 | + Get-ChildItem Env: | Sort-Object Name | Format-Table -AutoSize -Wrap |
| 117 | + displayName: '[Debug] Print Environment Variables' |
| 118 | +
|
| 119 | + # Install the .NET SDK from global.json. |
| 120 | + - template: /eng/pipelines/steps/install-dotnet.yml@self |
| 121 | + parameters: |
| 122 | + debug: ${{ parameters.debug }} |
| 123 | + |
| 124 | + # Restore dotnet local tools (pwsh, apicompat, etc.). |
| 125 | + - template: /eng/pipelines/steps/restore-dotnet-tools.yml@self |
| 126 | + |
| 127 | + # Clean any pre-existing .nupkg / .snupkg files from the packages/ directory |
| 128 | + # to ensure we only publish packages produced by this run. |
| 129 | + - pwsh: | |
| 130 | + Write-Host 'Cleaning packages/ directory...' |
| 131 | + Remove-Item -Force "$(Build.SourcesDirectory)/packages/*.nupkg" -ErrorAction SilentlyContinue |
| 132 | + Remove-Item -Force "$(Build.SourcesDirectory)/packages/*.snupkg" -ErrorAction SilentlyContinue |
| 133 | + Write-Host 'Done.' |
| 134 | + displayName: Clean packages/ directory |
| 135 | +
|
| 136 | + # On internal builds, download the strong-name signing key. |
| 137 | + - ${{ if eq(variables.isInternalBuild, true) }}: |
| 138 | + - task: DownloadSecureFile@1 |
| 139 | + displayName: Download Signing Key |
| 140 | + inputs: |
| 141 | + secureFile: netfxKeypair.snk |
| 142 | + name: keyFile |
| 143 | + |
| 144 | + # Run the Pack target via build.proj. |
| 145 | + - task: DotNetCoreCLI@2 |
| 146 | + displayName: build.proj - Pack (ReferenceType=Package) |
| 147 | + inputs: |
| 148 | + command: build |
| 149 | + projects: '$(Build.SourcesDirectory)/build.proj' |
| 150 | + arguments: >- |
| 151 | + -t:Pack |
| 152 | + -p:Configuration=${{ parameters.buildConfiguration }} |
| 153 | + -p:ReferenceType=Package |
| 154 | + -p:BuildNumber="$(Build.BuildNumber)" |
| 155 | + -p:BuildSuffix=ci |
| 156 | + $(signingKeyArg) |
| 157 | + --verbosity ${{ parameters.dotnetVerbosity }} |
| 158 | +
|
| 159 | + # List produced packages for diagnostics. |
| 160 | + - pwsh: | |
| 161 | + Write-Host 'Packages produced:' |
| 162 | + Get-ChildItem "$(Build.SourcesDirectory)/packages/*.nupkg" -ErrorAction SilentlyContinue | Format-Table Name, Length -AutoSize -Wrap |
| 163 | + Get-ChildItem "$(Build.SourcesDirectory)/packages/*.snupkg" -ErrorAction SilentlyContinue | Format-Table Name, Length -AutoSize -Wrap |
| 164 | + displayName: List produced packages |
| 165 | +
|
| 166 | + # Publish all .nupkg and .snupkg files from packages/ as a pipeline artifact. |
| 167 | + - task: PublishPipelineArtifact@1 |
| 168 | + displayName: Publish NuGet Packages |
| 169 | + inputs: |
| 170 | + targetPath: '$(Build.SourcesDirectory)/packages' |
| 171 | + artifactName: Packages |
| 172 | + publishLocation: pipeline |
0 commit comments