Selective Publishing of NuGet Packages in TeamCity

TeamCity NuGet plugin provides a build runner to publish a NuGet package to the feed. It makes it quite easy to make TeamCity create and publish a package from every build.

For some reason you may not need to publish every created NuGet package to the feed. In this post I'll describe how one can configure it with TeamCity.

To make it work you need to have two build configurations:

  • One configuration to create a NuGet package and publish it as a build artifact.
  • The second configuration to publish an artifact to a NuGet feed

In my example I will setup the build of YouTrackSharp project. To minimize the blog post I omit some details which are greatly described in the post by Hadi Hariri.

Configuration One

First let's create a build configuration that compiles a project, runs tests and produces a NuGet package. I set up a build configuration with 3 steps:

Note that I've omitted NuGet Package Publish runner. I also configured artifact paths to include created packages into the build artifacts. In the NuGet Package Pack runner I specified 'Output Directory' in the following way:

Next, in General Settings of the build configuration I specify 'Artifact Paths' to include created package files:

Now it's time to run the build and check it published created NuGet package(s) into the build artifacts:

Now the setup of the first step if finished. Let's move on to the other step.

Setting up the second build configuration

We need to setup a build configuration that publishes NuGet packages to the feed. This configuration contains the only one build runner: NuGet Packages Publish. The most interesting part is configuring dependencies of the second configuration I've created:

In the Dependencies section of the second build configuration I created a new artifact dependency to the first build configuration. TeamCity will download artifacts of the first build configuration into the checkout directory of the second configuration. In my example I prefer taking that latest successful build artifacts.

Publish a specific build

To publish a specific build of the NuGet package: open a build of the first configuration, notice a 'Promote...' action in the 'Build Actions' menu. All you need next is just to press Run button!

Download and Info:

For more information, see NuGet plugin home page at:
or download a latest build from TeamCity here
comments powered by Disqus