Published: 2019.01.02
Category: PowerShell
Publish module to
Module helps to publish module to PowerShell gallery for binary and script modules.
Publishing module to PowerShell gallery is very straight-forward task. To do it we just need to invoke command
If we are pushing to different repository than default, we also can provide PSRepostiory parameter
As I am publishing a lot I automated this repeatable task. Described module allows to be invoked in the directory of the module without pointing out exact psd1 file. Cmdlet will find it and process.
If a target module is binary one it will rebuild application and publish the newest version.
Also the Publish-ModuleTo allows to use UpdateModuleVersion switch, which will increase patch number (z in X.Y.Z).
This module is base for other, more specific one. Please check out Publish-ModuleToPowershellGallery
Examples
Go to the directory of the module and invoke
Publish-ModuleTo -PSRepository PSGallery -NuGetApiKey $nuGetApiKey Publish-ModuleTo -PSRepository PSGallery -NuGetApiKey $nuGetApiKey -Verbose -IncreaseModuleVersion
Switches
- IncreaseModuleVersion – it will increase patch number in the target module
- PSRepository – name of the repository where to put module. You could get all your repositories with Get-PSRepository cmdlet. By default here is inserted PSGallery so you can omit it if you have default configuration
- NuGetApiKey – your key which should be taken from profile on www.powershellgallery.com site
Diagram
