Skip to content

NuGetPush Task

Aaron Jensen edited this page Sep 27, 2019 · 1 revision

Overview

The NuGetPush task publishes a NuGet package (files with .nupkg extensions) to a NuGet repository using the nuget.exe push command. By default, it publishes all *.nupkg files in the output directory.

You must supply a Uri property and an ApiKeyID property, which should be the URI to the NuGet repository to publish to and the ID of the API key to use, respectively. API keys must be added in your build.ps1 script using Whiskey's Add-WhiskeyApiKey function.

The task will fail the build if a package with the current version already exists.

Because nuget.exe gives no indication if publishing failed or succeeded, the task checks for the newly published package after publishing. Some repositories take awhile to show available packages, so to skip this behavior, use the SkipUploadedCheck property.

Properties

  • Path: the path to the .nupkg files to publish. By default, all .nupkg files in the output directory are published.
  • Symbols: whether or not to publish symbols package. If this is true, the task only publishes files that match the *.symbols.nupkg wildcard.
  • Uri (mandatory): the URI to the NuGet repository to publish to. This is passes as-is to the nuget.exe push -source parameter. When publishing to nuget.org, use the value https://nuget.org/api/v2/package.
  • ApiKeyID (mandatory): the ID of the API key to use. Add API keys to your build.ps1 with the Add-WhiskeyApiKey function. The ApiKeyID property and the Add-WhiskeyApiKey function's ID parameter must match.
  • Version: the version of nuget.exe to use to publish. The default is to use the latest version of NuGet.
  • SkipUploadedCheck: set to true to not check if the package is immediately available after publishing. The default value is false, which means the build will fail if the just-uploaded package isn't available.

Examples

Example 1

Build:
- NuGetPush:
    Uri: https://nuget.org/api/v2/package
    ApiKeyID: nuget.org
    SkipUploadedCheck: true

Demonstrates how to publish to nuget.org. All *.nupkg files in the output directory are published.

Example 2

Build:
- NuGetPush:
    Uri: https://proget.example.com/nuget/NuGet/
    ApiKeyID: ProGet
    Path: $(WHISKEY_OUTPUT_DIRECTORY)\nuget\Whiskey*.nupkg

Demonstrates how to publish specific packages to an internal ProGet feed named "NuGet". In this example, only files in a nuget directory in the output directory that match the wildcard Whiskey*.nupkg are published.

Example 3

Build:
- NuGetPush:
    Uri: https://nuget.org/api/v2/package
    ApiKeyID: nuget.org
    Version: 4.1.0

Demonstrates how to use a specific version of NuGet. In this case, Whiskey will use version 4.1.0.

Example 4

Build:
- NuGetPush:
    Uri: https://proget.example.com/nuget/NuGet/
    ApiKeyID: ProGet
    Symbols: true

Demonstrates how to public symbol packages. In this case, only package whose filenames match wildcard *.symbols.nupkg are published.

Clone this wiki locally