|
| 1 | +# This is an example of an Azure DevOps pipeline |
| 2 | +# that builds GSF.CarbonAware nuget package and publish it as a pipeline artifact. |
| 3 | +parameters: |
| 4 | +- name: packageVersion |
| 5 | + displayName: Package Version |
| 6 | + type: string |
| 7 | + default: 1.0.0-beta |
| 8 | + |
| 9 | +trigger: |
| 10 | +- main |
| 11 | + |
| 12 | +pool: |
| 13 | + vmImage: 'ubuntu-latest' |
| 14 | + |
| 15 | +variables: |
| 16 | + csproj: 'src/GSF.CarbonAware/src/GSF.CarbonAware.csproj' |
| 17 | + buildConfiguration: 'Release' |
| 18 | + ArtifactNuGetName: 'packages-nuget' |
| 19 | + packageDir: '$(Build.ArtifactStagingDirectory)/packages/nuget' |
| 20 | + |
| 21 | +steps: |
| 22 | +- task: UseDotNet@2 |
| 23 | + displayName: 'Install .NET Core SDK' |
| 24 | + inputs: |
| 25 | + version: 6.x |
| 26 | + performMultiLevelLookup: true |
| 27 | + |
| 28 | +- task: DotNetCoreCLI@2 |
| 29 | + displayName: 'dotnet restore' |
| 30 | + inputs: |
| 31 | + command: restore |
| 32 | + projects: '$(csproj)' |
| 33 | + |
| 34 | +- task: DotNetCoreCLI@2 |
| 35 | + displayName: 'dotnet build $(buildConfiguration)' |
| 36 | + inputs: |
| 37 | + command: 'build' |
| 38 | + projects: '$(csproj)' |
| 39 | + arguments: > |
| 40 | + --configuration $(buildConfiguration) |
| 41 | +
|
| 42 | +- task: DotNetCoreCLI@2 |
| 43 | + displayName: 'dotnet pack $(buildConfiguration)' |
| 44 | + inputs: |
| 45 | + command: custom |
| 46 | + custom: pack |
| 47 | + arguments: > |
| 48 | + $(csproj) |
| 49 | + --configuration $(buildConfiguration) |
| 50 | + --output $(Build.ArtifactStagingDirectory)/packages/nuget |
| 51 | + -p:IncludeSymbols="true" |
| 52 | + -p:SymbolPackageFormat="snupkg" |
| 53 | + -p:Version=${{ parameters.packageVersion }} |
| 54 | +
|
| 55 | +# Alternatively, you can call the script to package the SDK. Replace the 2 tasks above (dotnet build and dotnet pack and replace with the following task) |
| 56 | +# - task: Bash@3 |
| 57 | +# displayName: 'Run script' |
| 58 | +# inputs: |
| 59 | +# targetType: 'filePath' |
| 60 | +# filePath: "$(System.DefaultWorkingDirectory)/scripts/package/create_packages.sh" |
| 61 | +# arguments: > |
| 62 | +# $(csproj) $(packageDir) |
| 63 | + |
| 64 | +- task: Bash@3 |
| 65 | + displayName: List packages |
| 66 | + inputs: |
| 67 | + targetType: 'inline' |
| 68 | + script: ls -l '$(Build.ArtifactStagingDirectory)/packages/nuget' |
| 69 | + |
| 70 | +- task: PublishPipelineArtifact@1 |
| 71 | + displayName: 'Publish Artifact: $(ArtifactNuGetName)' |
| 72 | + inputs: |
| 73 | + targetPath: '$(Build.ArtifactStagingDirectory)/packages/nuget' |
| 74 | + artifactName: '$(ArtifactNuGetName)' |
0 commit comments