1
votes

I am using Azure Pipelines from a Github Repository.

I was able to build a Dotnet Core class library using azure-pipelines.yml:

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'build' 

What to add to this script to publish a package to Azure Devops Artifacts after build?

And how to set each version release? From GitHub tag?

1

1 Answers

0
votes

Here is the documentation that gives a good set of yaml examples.

The bit you're going to zone in on is about pushing to an artifact feed.

steps:
- task: NuGetCommand@2
  displayName: 'NuGet push'
  inputs:
    command: push
    publishVstsFeed: '<feedName>'
    allowPackageConflicts: true

This section is about versioning your packages.

variables:
  Major: '1'
  Minor: '0'
  Patch: '0'

steps:
- task: NuGetCommand@2
  inputs:
    command: pack
    versioningScheme: byPrereleaseNumber
    majorVersion: '$(Major)'
    minorVersion: '$(Minor)'
    patchVersion: '$(Patch)'

We have done something similar to what is described in this versioning section to allow developers to increment the Major and Minor numbers and the Patch and Build numbers are derived from the build number ex. 1.2.1902.127. This tells us that this package is a member of 1.x family on feature 2 as the seventh revision of the build on Feb 12 of 2019.

We also want our assemblies versioned thus, so we have a couple powershell scripts that write the .csproj files with the appropriate property values. For .Net Framework projects we use MSBuild -t:Pack to leverage these properties for package versioning and for .Net Standard & Core we use the dotnet pack task.

note: NuGet.exe has a bug with package reference syntax for .Net Framework where the dependency tree isn't populated, so we use MSBuild to package those projects