I have a package on my TeamCity NuGet feed, built by TeamCity, but a dependent TC project cannot see it during package restore.
[14:05:02][Exec] E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.targets(88, 9): Unable to find version '1.0.17.0' of package 'MarkLogicManager40'.
[14:05:02][Exec] E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.targets(88, 9): error MSB3073: The command ""E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.exe" install "E:\TeamCity-BuildAgent\work\62023563850993a7\ProductMvc\packages.config" -source "" -RequireConsent -solutionDir "E:\TeamCity-BuildAgent\work\62023563850993a7\Web\ "" exited with code 1.
Note that the source
parameter in the NuGet command line is empty. Could this be the cause?
Restore packages manually using Visual StudioEnable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.
Find and install a packageIn Solution Explorer, right-click either References or a project and select Manage NuGet Packages.... The Browse tab displays packages by popularity from the currently selected source (see package sources). Search for a specific package using the search box on the upper left.
Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.
The default source is nuget.org, which has the following package source URL: https://api.nuget.org/v3/index.json .
As of today, NuGet.targets has the following way to specify custom feed(s):
<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="\\MyShare" /> <PackageSource Include="http://MyServer/" /> </ItemGroup>
Another option is to put NuGet.config next to the solution file:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> <add key="MyShare" value="\\MyShare" /> <add key="MyServer" value="http://MyServer" /> </packageSources> <activePackageSource> <add key="All" value="(Aggregate source)" /> </activePackageSource> </configuration>
Apparently NuGet custom feeds are set not via anything in the solution or project files, or nuget.config in the solution, but in the nuget.config in the developer's profile.
Over on TeamCity, there's no check by the agent of this config file, or writing to it, to ensure it contains the feed for the TeamCity server itself.
So package restore on TC using a custom TC feed won't 'just work'. You have to waste hundreds of pounds of client's money chasing your tail to discover all this and then set/copy your nuget.config from your profile into the profile of the user account running the build agent.
Horrible.
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