-
Notifications
You must be signed in to change notification settings - Fork 8
PublishPowerShellModule Task
The PublishPowerShellModule
task publishes a PowerShell module to a NuGet-based PowerShell repository (e.g. the PowerShell Gallery, ProGet, etc.). It uses the Publish-Module
function from the PowerShellGet
module.
You must supply the the path to the module's directory with the Path
property, the name of the repository with the RepositoryName
property, and the ID of the API key to use with the ApiKeyID
.
If a repository named RepositoryName
isn't registered, you must supply the RepositoryUri
parameter so that the task can register the repository. The RepositoryUri
parameter is passed to the Register-PSRepository
function's PublishLocation
and SourceLocation
parameters.
Before publishing, the ModuleVersion
property in the module manifest is updated to be the version of the current build, minus any prerelease or build metadata and the Prerelease
property in the PrivateData.PSData
section is updated to be the current prerelease metadata. Make sure you use prerelease metadata in the correct semver format for the repository to which you're publishing. If publishing a prerelease version, your module manifest must have a PrivateData.PSData.Prerelease
property, e.g.
@{
# snip
PrivateData = @{
PSData = @{
Prerelease = '';
}
}
# snip
}
-
Path
(mandatory): the path to the module root, i.e. the directory where the module's ".psd1" file is. -
RepositoryName
(mandatory): the name of the PowerShell repository. If a repository by this name isn't currently registerd, the task will register it. -
RepositoryUri
: the URI to which the module should be published. This is required if the repository namedRepositoryName
doesn't exist. This parameter is used to register a repository if one namedRepositoryName
doesn't exist. -
ApiKeyID
(mandatory): the ID of the API key to use. API keys are added to your build with theAdd-WhiskeyApiKey
function. -
ModuleManifestPath
: the path to the module's manifest (i.e. ".psd1" file). The default is to look for a manifest with the same name as the directory given by thePath
property. The task updates the module manifest with the current version and prerelease metadata. -
CredentialID
: the ID of the credential to use when registering the repository. UseAdd-WhiskeyCredential
in your build script to add credentials to the build. The credential is passed to theRegister-PSRepository
function'sCredential
parameter.
Publish:
- PublishPowerShellModule:
RepositoryName: PSGallery
RepositoryUri: https://powershellgallery.com/api/v2/
Path: Whiskey
ApiKeyID: PowerShellGallery
This example demonstrates how to publish to the PowerShell Gallery. It is how Whiskey itself gets published. The PowerShellGallery
is added in Whiskey's build.ps1 build script like this:
Add-WhiskeyApiKey -Context $context -ID 'PowerShellGallery' -Value $apiKey
- Common Task Properties
- AppVeyorWaitForBuildJob
- CopyFile
- Delete
- DotNet
- Exec
- File
- GetPowerShellModule
- GitHubRelease
- InstallNodeJs
- LoadTask
- Log
- MergeFile
- MSBuild
- NuGetPack
- NuGetPush
- NuGetRestore
- NUnit2
- NUnit3
- Parallel
- Pester
- Pipeline
- PowerShell
- ProGetUniversalPackage
- PublishBitbucketServerTag
- PublishBuildMasterPackage
- PublishNodeModule
- PublishPowerShellModule
- PublishProGetAsset
- PublishProGetUniversalPackage
- SetVariable
- SetVariableFromPowerShellDataFile
- SetVariableFromXml
- TaskDefaults
- Version
- Zip