How should I tell TeamCity's NuGet Installer build step to use both NuGet.org and the TeamCity provided packages source?

11,673

Solution 1

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.

Solution 2

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.

Solution 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.

Solution 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.

Share:
11,673

Related videos on Youtube

CoderDennis
Author by

CoderDennis

Dennis cut his coding teeth by teaching himself BASIC on a Texas Instruments TI-99/4A computer in the early 80's. His earliest memory of debugging a program was when he found that his mother had typed the letter O instead of the digit 0 in a hexadecimal string that defined the graphics of a program she copied from the listing in a magazine. After discovering Delphi 1.0 during college, he went to work on a fax broadcast system and other telephony projects. In the late 90's he worked with a few record labels to put software on their music CD's. This included Windows screen savers of album art work and a music player that scrolled the lyrics of each song across the screen -- all written in Delphi. After that, he spent about 5 years doing web development in PHP (even working with a PHP MVC Framework) before discovering ASP.NET and C#. He remained somewhat proud of the fact that he had never worked with Visual Basic until starting a job in 2007 where it was the company's language of choice for developing Microsoft Office customizations for the legal industry. Even though he got lost any time he tried to look at VB6 code, with the advent of LINQ to XML and XML Literals in VB9, he was happy to be a VB.NET developer. In 2012, upon returning to full-time web development, he was pleased to discover that working with JavaScript sure isn't what it used to be. He has been running Elm in production since June 2018 -- no runtime errors, for the win! From 2014 to 2019 he organized the Dallas Functional Programmers user group (dallasfp.com) and enjoyed exploring various FP languages with people who share his passion.

Updated on September 15, 2022

Comments

  • CoderDennis
    CoderDennis over 1 year

    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.

  • mare
    mare over 11 years
    Does this workaround work with TC's private feed? I get an error in msbuild step saying that it cannot request credentials in non-interactive session. I am trying to find a solution using private feed, maybe you can help?
  • CoderDennis
    CoderDennis over 11 years
    I haven't tried to set up a private feed, so I don't know if this would work for that scenario.
  • absynce
    absynce about 11 years
    Yes, this is what I had to do too. Here's an example: <ItemGroup Condition=" '$(PackageSources)' == '' "> <PackageSource Include="https://nuget.org/api/v2/" /> <PackageSource Include="http://exampleprivatefeed/" /> </ItemGroup>
  • Admin
    Admin about 11 years
    I believe it's true that you do not need the NuGet Installer step IF you only want to pull down the current package versions installed in the projects. If you want to first update those packages specified in packages.config, you need to run the NuGet Installer step first before the build to pull updates based on your Nuget Installer step settings for updating. In our nuget.targets file I have added our custom nuget internal server so current packages are pulled down, works great, but that doesn't get updates, so hence the Nuget Installer step. Sound reasonable or off-base?