A short while ago, Package Management in VSTS became publicly available. Agreed, the features in the initial version are not overwhelming, but the potential is very high.
If you are not familiar yet, with Package Management in VSTS , I highly recommend you take a look at the documentation on the Visual Studio site, to get acquainted.
The quirks of semantic versioning
Package Management is broadly used in our programming world. Of course, in the .NET world, we use NuGet to share our packages with the world or our internal department.
Versioning NuGet packages in a Continuous Delivery landscape has some challenges. Matt Cooper wrote a great blog series around this on the MSDN Blogs (Part 1, Part 2, Part 3)
In order to control the quality of the packages, the most used mechanism is Semantic Versioning (or SemVer).
The “difficult part” about this mechanism, is that you need to version your package before you actually know the quality of the package.
Introducing Release Views
Because Semantic Versioning has some “downside” the VSTS team introduced something new into VSTS Package Management. Release Views. A Release View is extra meta information about the package that was pushed. Within VSTS they call it a descriptor. With these release view you can “mark” your package with a certain quality without actually changing the version. For example mark the package as “CI” or “Beta” or “Release”
By connecting to the feed with this descriptor added as extra information, you can filter the feed on a certain quality.
E.g.
All packages https://roadtoalm.pkgs.visualstudio.com/_packaging/RoadToALMFeed/nuget/v3/index.json
Only Beta packages https://roadtoalm.pkgs.visualstudio.com/_packaging/RoadToALMFeed@Beta/nuget/v3/index.json
Of course you can create your own release views. This is all described in the VSTS Documentation
- https://www.visualstudio.com/en-us/docs/package/feeds/about-release-views
- https://www.visualstudio.com/en-us/docs/package/feeds/views
Promote your package programmatically with the VSTS REST API
Currently you can only promote the package with the UI and with the REST API. But THE place to promote packages to a certain quality is of course your release pipeline. To overcome this I created tis Powershell Script, which you can use to promote your package to the desired quality.
- First create a Personal Access Token (as described here )
- Download the Set-PackageQuality.ps1 script from my GitHub
- There is a Test script as well that you can use to call this script. Just fill in the environment variables and run
- Add the script to Git and publish the script as Build Artifact
- Create a release pipeline, add a powershell task and call the script with the right parameters
The powershell script looks like this
function Set-PackageQuality { [CmdletBinding()] [OutputType([object])] param ( [string] $feedName="", [string] $packageId="", [string] $packageVersion="", [string] $packageQuality="" ) $token = New-VSTSAuthenticationToken $releaseViewURL = "$basepackageurl/$feedName/nuget/packages/$packageId/ versions/$($packageVersion)?api-version=3.0-preview.1" #Queue a new build for this definition $json = @" { "views": { "op":"add", "path":"/views/-", "value":"$packageQuality" } }, "@ $response = Invoke-RestMethod -Uri $releaseViewURL -Headers @{Authorization = $token} -ContentType "application/json" -Method Patch -Body $json return $response }
Just look up the VSTS REST API for further details on how to update NuGet packages.
You would call this function something like this Set-PackageQuality.ps1 -feedName RoadToALMFeed -packageId RoadToALM.Common -packageVersion 1.0.36.1 -packageQuality Beta
Download the source here – https://github.com/renevanosnabrugge/VSTS-SetPackageQuality
Good luck !
Update 17-1-2017: My colleague Kees Verhaar submitted a Pull request to make this work for NPM as well ! For that he added a FeedType parameter to the script. Thanks Kees.
I sent a pull request to make the script also work with NPM feeds. I hope that’s useful for someone!
How can I DEmote a package OUT of release view or prerelease view?
You can’t. At least. I did not found it. Once it has been “released” people can use it and therefore deletion might cause trouble.
I can’t find it either. The problem is sometimes people make mistakes. This is not for public consumption anyway. We only use package management internally. We have dozens of products with shared code. Nuget helps tremendously with that. However we can’t be tagging packages as release accidentally.
Frustrating that you can’t UNDO something so simple.
Thank you for confirming my suspicions. 😀