Project

PSPublishModule

Build, test, version, sign, and publish PowerShell modules with reusable PowerForge pipelines.

Stars 48
Forks 16
PowerShell Gallery downloads 17,213
Release v3.0.169
Language: C# Updated: 2026-10-17
Command

Publish-NugetPackage

Module PSPublishModule
Inputs
None

Pushes NuGet packages to a feed using dotnet nuget push.

Syntax

Publish-NugetPackage -ApiKey <String> -Path <String[]> [-SkipDuplicate] [-Source <String>] [<CommonParameters>]
#
Parameter set: Source
Publish-NugetPackage [-ApiKey <String>] [-InstallPrerequisites] -Path <String[]> -ProfileName <String> [-SkipDuplicate] [<CommonParameters>]
#
Parameter set: Profile

Description

Searches the provided -Path roots for *.nupkg files and pushes them using the .NET SDK.

Use -SkipDuplicate for CI-friendly, idempotent runs.

Examples

Authored help example

Publish all packages from a Release folder

Publish-NugetPackage -Path '.\bin\Release' -ApiKey $env:NUGET_API_KEY -SkipDuplicate

Publishes all .nupkg files under the folder; safe to rerun in CI.

Publish to a custom feed

Publish-NugetPackage -Path '.\artifacts' -ApiKey 'YOUR_KEY' -Source 'https://api.nuget.org/v3/index.json'

Use a different source URL for private feeds (e.g. GitHub Packages, Azure Artifacts).

Publish to a saved Azure Artifacts profile

Publish-NugetPackage -Path '.\artifacts' -ProfileName 'Company' -InstallPrerequisites -SkipDuplicate

Resolves the Azure Artifacts NuGet v3 source from the saved profile, installs missing credential-provider prerequisites when requested, and lets the Azure Artifacts Credential Provider handle Entra-backed authentication.

Parameters

-ApiKey String required in Source
API key used to authenticate against the NuGet feed. For Azure Artifacts profiles this defaults to a non-secret placeholder used by NuGet clients; for GitHub Packages profiles this defaults from GITHUB_TOKEN or GH_TOKEN.
-Path String[] required
Directory to search for NuGet packages.
-SkipDuplicate SwitchParameter optional
When set, passes --skip-duplicate to dotnet nuget push. This makes repeated publishing runs idempotent when the package already exists.
-Source String optionalsets: Source
NuGet feed URL.
-InstallPrerequisites SwitchParameter optionalsets: Profile
Installs missing private-gallery prerequisites before profile-backed Azure Artifacts package publishing.
-ProfileName String requiredaliases: Profilesets: Profile
Saved private gallery profile name for Azure Artifacts package publishing.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.