问题
I'm having trouble with my NuGet Installer build step.
We're using both official NuGet.org packages and our own packages hosted on the TeamCity NuGet server. If I leave Packages Sources blank, then packages from nuget.org are found, but as soon as I specify %teamcity.nuget.feed.server%
as the package source, then packages from nuget.org are not found.
I tried setting Packages Sources to include both, but it still isn't working for official nuget.org packages.
https://nuget.org/api/v2/
%teamcity.nuget.feed.server%
Is that not the right URL for the nuget.org package source? How do I tell it to use both sources?
I asked this on the JetBrains Developer discussion board, but haven't gotten any responses.
回答1:
Had same problem, funny enough my Nuget sources were specified as https://www.nuget.org/api/v2/
http://nugetserver/nuget
Adding a forward slash on the second url to make it http://mynugetserver/nuget/
fixed the problem.
Took me a while to figure out. Now my Nuget-installer build step is running fine.
回答2:
Apparently the NuGet Installer build step is not even needed. I edited the .nuget/NuGet.targets
file to include both paths and removed the NuGet Installer build step and it works now.
When originally setting up TeamCity for this solution, it didn't work without the NuGet Installer step, so I don't know what else I've done differently to make this work, but maybe the NuGet.targets file was the key all along.
The comment on this blog post pointed me in the right direction.
回答3:
You can modify the NuGet.Config in AppData local folder for the user that TeamCity runs under and not modify each project's .targets file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!--<add key="repositoryPath" value="J:\TeamCity7\buildAgent\work\my_shared_packages_dir" />-->
</config>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
<add key="MMG TeamCity Nuget Server" value="http://myteamcityserver/guestAuth/app/nuget/v1/FeedService.svc" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
The NuGet.exe inside of .nuget folder in each project will respect the configs set here first, then apply any "overrides" done at the .targets file.
回答4:
Same problem here. I am using TeamCity v10, Nuget step is required (no .targets file in my solution). However, I used another approach to add the "extra" package source:
c:\BuildAgent\tools\NuGet.CommandLine.2.7.0\tools\Nuget.exe sources Add -Name TeamCity-feed -Source http://myteamcityserver/guestAuth/app/nuget/v1/FeedService.svc/
After that, I added a Nuget installer step and did not specify anything in the package source box in TeamCity, now both packages from public feed nuget.org and my internal feed could be restored without problems.
来源:https://stackoverflow.com/questions/12897747/how-should-i-tell-teamcitys-nuget-installer-build-step-to-use-both-nuget-org-an