Package: NuGet Publisher

Last Update: 4/7/2017

Team Services | TFS 2017 | TFS 2015 Update 3 | Previous versions (XAML builds)

Publish your NuGet package to a server and update your feed.

TIP

Looking for help to get started? See Use Team Build to restore and publish NuGet packages.

Demands

None

Arguments

Argument Description
Path/Pattern to nupkg

Specify the packages you want to publish.

  • Default value: **\*.nupkg;-:**\packages\**\*.nupkg
  • To publish a single package, click the ... button and select the file.
  • Use single-folder wildcards (*) and recursive wildcards (**) to publish multiple packages.
  • Use variables to specify directories. For example, if you specified $(Build.StagingDirectory)\packages as the package folder in the NuGet Packager step, you could specify $(Build.StagingDirectory)\packages\**\*.nupkg here.
Feed type
  • External NuGetFeed publishes to an external server such as NuGet or MyGet. After you select this option, you create and select a NuGet server endpoint.
  • Internal NuGet Feed publishes to an internal or Visual Studio Team Services feed. After you select this option, you specify the internal feed URL.
Advanced
NuGet Arguments (Optional) Additional arguments passed to nuget push.
Path to NuGet.exe (Optional) Path to your own instance of NuGet.exe. If you specify this argument, you must have your own strategy to handle authentication.
Control options

Examples

You want to package and publish some projects in a C# class library to your Team Services feed.

`-- Message
    |-- Message.sln
    `-- ShortGreeting
        |-- ShortGreeting.csproj
        |-- Class1.cs
        `-- Properties
            |-- AssemblyInfo.cs
    `-- LongGreeting
        |-- LongGreeting.csproj
        |-- Class1.cs
        `-- Properties
            |-- AssemblyInfo.cs

Prepare

AssemblyInfo.cs

Make sure your AssemblyInfo.cs files contain the information you want shown in your packages. For example, AssemblyCompanyAttribute will be shown as the author, and AssemblyDescriptionAttribute will be shown as the description.

Variables tab

Name Value
$(BuildConfiguration) release
$(BuildPlatform) any cpu

Options

Setting Value
Build number format $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

Publish to Visual Studio Team Services

Make sure you've prepared the build as described above.

Create the feed

See Create a feed.

Build steps

Build: Visual Studio Build
Build: Visual Studio Build

Build your solution.

  • Solution: **\*.sln
  • Platform: $(BuildPlatform)
  • Configuration: $(BuildConfiguration)
Package: NuGet Packager
Package: NuGet Packager

Package your projects.

  • Path/Pattern to nuspec files: **\*.csproj
  • Use Build number to version package: Selected
  • Advanced, Configuration to Package: Release
Package: NuGet Publisher
Package: NuGet Publisher

Publish your packages to Team Services.

Publish to NuGet.org

Make sure you've prepared the build as described above.

Register with NuGet.org

If you haven't already, register with NuGet.org.

Build steps

Build: Visual Studio Build
Build: Visual Studio Build

Build your solution.

  • Solution: **\*.sln
  • Platform: $(BuildPlatform)
  • Configuration: $(BuildConfiguration)
Package: NuGet Packager
Package: NuGet Packager

Package your projects.

  • Path/Pattern to nuspec files: **\*.csproj
  • Use Build number to version package: Selected
  • Advanced, Configuration to Package: Release
Package: NuGet Publisher
Package: NuGet Publisher

Publish your packages to NuGet.org.

  • Path/Pattern to nupkg: **\*.nupkg
  • Feed type: External NuGet Feed
  • NuGet Server Endpoint: endpoint manage

    1. Click New Service Endpoint, and then click Generic.
    2. On the Add New Generic Connection dialog box:

      • Connection Name: NuGet
      • Server URL: https://nuget.org/
      • User name: {your-name}
      • Password/Token Key: Paste API Key from your NuGet account.

NuGet Packager Create a NuGet package from either a .csproj or .nuspec file

NuGet Installer Install and update NuGet package dependencies

Q & A

Where can I learn about Visual Studio Team Services package management?

Package Management in Team Services and TFS

Where can I learn more about NuGet?

NuGet Docs Overview

NuGet Create Packaging and publishing

NuGet Consume Seting up a solution to get dependencies

What happens if no packages are found to publish? Does the task succeed?

Yes

Can I delete a package?

Depends on the server:

Do I need a build agent?

You need at least one agent to run your build. Get an agent.

I can't select a default agent queue and I can't queue my build. How do I fix this?

See queues.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.