Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS NuGet tricks that I don't already know about?

Tags:

nuget

tfsbuild

So, I've enabled package restore on my solutions - Install-Package NuGetEnablePackageRestore

I've installed and updated NuGet on the TFS Build Server

I've created the environment variable on the TFS Build Server - http://www.centrolutions.com/blog/post/2012/07/05/NuGet-and-TFS-2010-Automated-Build.aspx

I've deleted all of my packages.config files and started over again on every project.

I've added the .nuget folder path to the build job, along with a defined Build Agent Folder

I've almost finished my noose and plan on hanging myself at dawn...is there something I'm missing?

Forgot to put TFS Build errors

C:\Builds\10.......nuget\nuget.targets (76): Package restore is disabled by default. To give consent, open the Visual Studio Options dialog, click on Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'.

and

C:\Builds\10.......nuget\nuget.targets (76): The command ""C:\Builds\10.......nuget\nuget.exe" install "C:\Builds\10......\packages.config" -source "" -o "C:\Builds\10......\packages"" exited with code -1.

Removed full path for security.

DISCOVERY:

My TFS administrator set up the environment variable as a USER variable! I just figured I would ask her to show me exactly how she configured it and as soon as she did, I realized it was wrong.

I am no longer getting the Package restore error...wooo! I am however getting "Unable to find version" errors, which makes me think that the TFS box doesn't know of the proper package sources. I've verified that the package source is accessible from the TFS build box, also I've configured NuGet on that box to have reference to the package shares.

Is it possible to do this without a package server? I have been using file shares for all of my local builds, but I'm wondering if the rules change when it hits the TFS box. Do I need to define my package sources in the Nuget.config file?

like image 425
farina Avatar asked Aug 07 '12 23:08

farina


3 Answers

Starting with NuGet 2.0, you need to consent NuGet to download packages during build (privacy concern). More info here : http://blog.nuget.org/20120518/package-restore-and-consent.html

The option to give consent in the UI has been added with NuGet Package Manager 1.8. It's the 3rd item under Tools->Options->Package Manager->General : "Package Restore : Allow NuGet to download missing packages during build".

Alternatively you can give consent by setting the EnableNuGetPackageRestore Environment variable to true.

like image 163
Alexandre Dion Avatar answered Nov 12 '22 16:11

Alexandre Dion


The problem ended up being that the TFS administrator used a "user variable" for the EnableNuGetPackageRestore environment variable. I never would have guessed this right off the bat :(.

I went and watched her configure it again, and noticed that it was wrong...had her correct it, and now it works fine.

Thanks for all the advice!

like image 20
farina Avatar answered Nov 12 '22 16:11

farina


If you enabled package restore, then you can configure the package sources using the <PackageSources> element in the NuGet.targets file you'll find in the $(SolutionDir).nuget folder.

Can you verify these point to the correct location, and whether that path is accessible from the build server?

like image 37
Xavier Decoster Avatar answered Nov 12 '22 17:11

Xavier Decoster