I have created a Nuget Server using Teamcity (running on a virtual machine in internet) and created the build that publishes a package into it.
I also have another project that needs to use that package. This project is built on teamcity as well. On my local Visual Studio I added the nuget feed uri, installed the package and everything works fine. But when I try to build it on teamcity it says that "Package not found".
So my question is : "How to add the custom nuget feed to TeamCity build?"
When using TeamCity as a NuGet server, there are three ways to publish packages to the feed: 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. via the NuGet Publish build step.
In visual studio, select Preferences from the menu bar. Select NuGet, and then select Sources. Select Add, and then enter your feed's name, the source URL, a userName (any string), and your personal access token. Select OK.
Cloudsmith provides public & private feeds for NuGet. NuGet is an open-source package manager designed for the Microsoft development technologies. The NuGet repository support at Cloudsmith is compatible with Chocolatey, so if you're looking to manage packages on Windows, that's our recommended approach.
The NuGet package sources are configured through Visual Studio, but they're stored in a per-user configuration file, found at c:\Users\$USER\AppData\Roaming\NuGet\NuGet.config
. The entry for the TeamCity package source needs to be added to the config file of the build agent user that's running your builds.
EDIT: ladenedge documents a good solution that didn't exist when I originally answered this question. The solution is especially useful if you don't have admin access to the build agent or want to configure package sources on a per-project basis.
NuGet can now read sources from the NuGet.targets
file stored with the source itself as explained in the answer to a duplicate question.
<ItemGroup Condition=" '$(PackageSources)' == '' "> <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used --> <!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list --> <PackageSource Include="https://nuget.org/api/v2/" /> <PackageSource Include="https://my-nuget-source/nuget/" /> </ItemGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With