Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS2012 build server not restoring NuGet packages from in-house repository

Tags:

nuget

tfsbuild

I've set up an in-house NuGet repository (a shared folder on one of our servers), and have added it to the "Available Sources" list in the Visual Studio NuGet settings on my PC. I'm able to successfully install a package into my solution from this repository.

However on the TFS server the build is failing because it can't restore this particular package (message: "Unable to find version 'xxx' of package 'xxx'"). The solution is configured for "enable NuGet package restore", which works fine for packages installed via nuget.org. It's just not restoring the package from our internal repository.

Permissions on the repository folder/share are fine. What am I missing?

I'm guessing I have to configure Visual Studio's "available sources" on the TFS server too, but presumably these settings are user-specific? The build service runs as NETWORK SERVICE, so how can I configure NuGet for this user?

like image 290
Andrew Stephens Avatar asked Sep 17 '14 15:09

Andrew Stephens


People also ask

How do I force a NuGet package to restore?

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

Does dotnet build restore NuGet packages?

The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. In most cases, you don't need to explicitly use the dotnet restore command, since a NuGet restore is run implicitly if necessary when you run the following commands: dotnet new.

Where NuGet packages are stored locally?

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder. When using the packages.

How do I fix NuGet recovery failed?

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.


1 Answers

You can add the source to a machine-wide config on the TFS build server and it will be included in the list of sources when doing package restores.

What I did was create a file %ProgramData%\NuGet\Config\sources.config that contained:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="internal source" value="http://internal_server/nuget/" />
  </packageSources>
</configuration>

The name of the file doesn't matter, it's the location of the file. Nuget picks up any .config files under that folder.

http://docs.nuget.org/docs/reference/NuGet-Config-File#NuGet_config_extensibility_point

UPDATE 2016-11-18 According to http://blog.nuget.org/20161121/introducing-nuget4.0.html (under breaking changes), VS 2017+ and NuGet 4.0+ changes the location of the machine-wide config folder to %ProgramFiles(x86)%\NuGet\Config\.

like image 155
Jeff Shepler Avatar answered Oct 17 '22 04:10

Jeff Shepler