If you want to publish your NuGet packages to a limited audience, e.g. to use them internally, you can use TeamCity as a NuGet feed. Since TeamCity 2018.2, you can configure multiple NuGet feeds for a project in TeamCity.
note
TeamCity running on any of the supported operating systems (Windows, Linux, macOS) can be used as a NuGet feed.
Enabling NuGet Feed
To start using TeamCity as a NuGet Server, you need to enable the NuGet Feed at the project level.
Go to the NuGet Feed page on the Project Settings page and enable the feed. Since TeamCity 2018.2, the built-in TeamCity NuGet feed supports API v1/v2/v3. On the page you will see the following feed endpoints:
If you have enabled guest user you will see the toggle between Basic HTTP authentication and Guest authentication for NuGet feed Endpoints.
Basic HTTP authentication (with httpAuth prefix) - to access packages user should have "View project" permission.
Guest authentication (with guestAuth prefix) - if guest user login was enabled packages will be visible to all users which have access to TeamCity server.
To reference TeamCity project feeds, use parameters as follows: teamcity.nuget.feed.<authSchema>.<projectName>.<feedName>.<apiVersion>
where authSchema could be guestAuth/httpAuth, apiVersion is v1/v2/v3, for instance: teamcity.nuget.feed.httpAuth._Root.default.v2
On upgrading TeamCity to version 2018.2 or later, the deprecated parameters referencing the global NuGet feed will be automatically converted to the references to the default NuGet feed:
By default, TeamCity will not add .nupkg artifacts published by builds into the project NuGet feed. You can select one of the following options:
to index packages published by selected build configurations only, add the NuGet packages indexer build feature to these build configurations
to index all .nupkg files published as build artifacts in the project, enable Automatic NuGet Packages Indexing on the NuGet Feed page of the project settings
use the NuGet Pack build step with the Publish created packages to build artifacts checkbox.
Besides, .nupkg files indexing is performed by the agent itself while publishing build artifacts.
note
Deleting a NuGet Feed with all its contents from a project will remove all NuGet Packages Indexer features pointing to this feed.
Using NuGet push command
To publish .nupkg file into TeamCity NuGet feed during the build, you can specify the NuGet feed URL as a package source and the %\teamcity.nuget.feed.api.key% value as a feed key in the following build steps:
Publishing of NuGet symbol packages to an internal TeamCity feed may cause issues when using an external source server. See the corresponding issue in our public tracker.
Using TeamCity NuGet Feed
You can add TeamCity NuGet feeds as package sources package on your developer machine, e.g. to use packages during development: use the nuget sources command or NuGet package management in your IDE.
You can use TeamCity NuGet feeds to restore packages in your builds: when the NuGet Installer or NuGet Publish build step is used, TeamCity will use the credentials provider to automatically authenticate requests to the private TeamCity NuGet feeds.
tip
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. To avoid cleanup of artifacts in a specific build, pin this build.
Internet Explorer settings may need to be set to trust the TeamCity Server when working in a mixed authentication environment.