Hello!

I’ve been writing a PowerShell module that I want other developers to be able to use, so I decided to use the artifacts part of Azure DevOps as I’ve set up a build to run some tests and run PsScriptAnalyzer prior to publishing the module at the end of the build as an artifact. I figured that using the Artifacts to store my artifacts was sensible instead of leaving them hanging around old builds.

Anyway, I followed this sample how to, but the script provided is a little out of date; I needed to provide a credential when running the Publish-Module otherwise it wouldn’t work, and the V2 version of the url is not working when I run the Get-PsRepository, so I altered it so that the entire url is passed in. This can be got by going to the artifacts part of the Azure DevOps and on the feed you want to publish to select Nuget.exe and the url is there. Note that for PowerShell modules you do not need to provide a Nuget package.

So if you’re adding this as a step in your Releases then you will need to supply values for the following three params - PackageSourceUrl AzDOArtifactFeedName AzDOPat

UPDATE!

Oh! And if you are getting this error -

Register-PSRepository : The specified Uri 'https://some-nuget/api/v2' for parameter 'SourceLocation' is an invalid Web Uri. 
Please ensure that it meets the Web Uri requirements.

and you have the latest version of PowerShellGetinstalled and don’t ahve the https endpoint bug mentioned on StackOverflow then update the url from V2 to V3. It is in this script, but every single example I have seen online uses the V2 URL, and whenever I used the V2 version of the Nuget URL I got the error above. Weird!