Wow, day 7 already! And for today’s post, we getting meta.

I have a few builds on VSTS that run PSScriptAnalyzer on some PowerShell modules, and also runs some tests. After these steps have run successfully I publish to both NuGet and PowerShell Gallery (yes that’s right, Continuous Development FTW).

Packaging via NuGet is simple enough: there’s several out-of-the-box NuGet steps in VSTS, including even a Custom step that allows you to submit version number/prefix. Tidy! But! For publishing to the PowerShell Gallery, you have to go to the Marketplace. Not that having to install a third party tool is a bad thing!

So it all works very well, however there is one snag here, and it’s not a fault of the tool. The problem here is the version number of the Module: the keen-eyed amongst you will have noticed that I’m using the build number in the version number of the NuGet package. And there’s no way to do this for the Module before I publish to the Gallery.

So, with a little effort, I have written some PowerShell that will alter the ModuleVersion in the psd1 file.

As brute force as it is, it works.