TeamCity integrates with NuGet package manager and provides:
- NuGet feed based on the builds' published artifacts
- A set of NuGet runners to be used in builds on Windows OS; and since TeamCity 2017.1 on Linux and Mac OSX when Mono is installed on the agent (NuGet 3.2 is strongly recommended with Mono).
The NuGet Dependency Trigger, which allows triggering builds on NuGet feed updates.
On this page:
Typical Usage Scenarios
- To install packages from a public feed, add the NuGet Installer build step.
- To create a package and publish it to a public feed, add the NuGet Pack and NuGet Publish build steps.
- To create a package and publish it to the internal TeamCity NuGet Server, enable TeamCity as a NuGet Server (see the section below), use the NuGet Pack build step and NuGet Publish build steps.
- To trigger a new build when a NuGet package is updated, use NuGet Dependency Trigger.
Installing NuGet to TeamCity agents
The NuGet trigger and the NuGet-related build runners require the NuGet command line binary configured on the server. They are automatically distributed to agents once configured.
To install NuGet.exe on TeamCity:
- Go to the Administration | Tools tab.
- Click Install tool and select NuGet.exe.
Select whether you want to download (default) NuGet from the public feed or upload your own NuGet package containing
a) If the Download radio button is chosen, select the NuGet version to install on all build agents.
b) If the Upload radio button is selected, choose your own NuGet package.
Specify whether this NuGet version will be default using the related check-box.
- Click Add to install the selected NuGet version.
Using TeamCity as NuGet Server
If for some reason you don't want to publish packages to public feed, e.g. you're producing packages that are intended to be used internally; you can use TeamCity as a NuGet Server instead of setting up your own repository.
To start using TeamCity as a NuGet Server, go to the Administration | NuGet Feed page (available to server system administrators), and click Enable. Two different links will be displayed on the page: for public (with
guestAuth prefix) and private (with
httpAuth prefix) feed. If Public Url is not available, you need to enable the Guest user login in TeamCity on the Administration | Global Settings page.
When the NuGet Server is enabled, all NuGet published packages will be indexed and will appear in NuGet feed. The feed will include the packages from the build configurations where the currently authenticated user has permission to view build artifacts ("View project" permission).
When you have TeamCity NuGet server enabled:
You can publish packages to the feed either as build artifacts of the NuGet Pack build step (using the Publish created packages to build artifacts checkbox - in this case you do not need the NuGet Publish build step) or via the NuGet Publish build step (since TeamCity 2017.1)
You can add TeamCity NuGet server to your repositories in Visual Studio to avoid having to type in long URLs each time you want to read from a specific package repository (add NuGet repository and specify the public URL provided by TeamCity when enabling NuGet server).
The packages available in the feed are bound to the builds' artifacts: they are removed from the feed when the artifacts of the build which produced them are cleaned up.
You do not need to specify credentials for the internal NuGet feed access; if NuGet Feed Credentials are specified, they are ignored.
If the build artifacts are changed under TeamCity Data Directory manually, you need to instruct TeamCity to reindex NuGet feed. For that, click "reset" link for "buildsMetadata" under Administration > Diagnostic > Caches.
Internet Explorer settings may need to be set to trust the TeamCity Server when working in a mixed authentication environment.
For a step-by-step example of NuGet setup see blog post: Setting up TeamCity as a native NuGet Server.