MFH Labs : Azure DevOps pipeline with Azure Artifact NuGet Feed for Dev environment

Create a feed of the Azure Artifact

Go to the Artifacts and create new feed. Just give it name and hit Create. Then you will see the new repository for NuGet Package.

Create new feed

Create a build pipeline

You might automate the build/pack/publish to NuGet.

Add VersionSuffix

For the development environment, we don’t want version up the semantic version, however, if we build a new build, we want to distinguish it by using BUILD_ID of the Azure DevOps. Let’s add $(VersionSuffix) on your csproj file, Version section.

<Version>0.0.1-alpha$(VersionSuffix)</Version>

For the production, it become blank since the $(VersionSuffix) is not set. however, for development environment, I’d like to make it like 0.0.1-alpha-210.0.1-alpha-22 and cleary change the name not for hit cache and update build everytime. 21 and 22 will be the BUILD_ID of the pipeline. If you add -alpha or -beta or -rc , it becomes pre-release.

Pre-release versions in NuGet packages

Guidance for building pre-release packages

docs.microsoft.com

The pipeline is almost the same as the template of Asp .NET Core. I change little bit for it.

Pipeline

Build

The point is, In case of build, you can specify the --version-suffix option with the parameter “-$(Build.BuildId)” It will overwrite the $(VersionSuffix) by the Build_ID of the CI pipeline.

https://medium.com/media/31a310e5b5043394a5df5652e2e77aab

Pack

Also, you need to add the Version Suffix on pack. If you are using GUI, you can go Advanced tab to configure it.

https://medium.com/media/34d4643263d3d6fb59d0027b03547ebc

Nuget Push

BTW, I still prefer to start with classic GUI. It is very easy and eventually it can convert into yaml if necessary. Also, we can use template which is well defined. In this case, we can choose the Artifacts feed with drop down menu.

Now your Nuget Package is upload to the Artifacts

Nuget Push

Artifact

If you queue build, you will see the new version is upload to the Artifacts.

Feed

If you click Connect to feed, you can see the Connection information to this repo.

Connect to feed

Visual Studio

Configure the package source.

Then you will see all NuGet package for all build_id.

Package Manager

Conclusion

Creating a repository for Nuget Package is pretty easy with Azure DevOps. 🙂

This is the yaml for export from the pipeline.

https://medium.com/media/7c4b98135f708253635315b73a5ee39c

63