Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure where NuGet.exe Command Tool line looks for packages

We have successfully set up a couple of local package repositories using the NuGet.Server package and hosted them on a local IIS webserver. We are able to connect from the Package Manager and install no problem. So these are working fine.

In order for us not to have to check in our packages folder we have included the following command line in each project file that includes NuGet references. This works, if the NuGet.exe is in the path on the CI build agent.

However, I would like to move the source configuration form the command line in every project file and put it in just one place, preferably where other pesky developers can't change it ;)

<Target Name="BeforeBuild">
    <Exec Command="nuget install $(ProjectDir)packages.config -s 
       http://domain:80/DataServices/Packages.svc/;
        http://domain:81/DataServices/Packages.svc/ 
       -o $(SolutionDir)packages" />
</Target>

Is there a better way?

like image 362
Daniel Dyson Avatar asked Sep 22 '11 11:09

Daniel Dyson


1 Answers

Yes there is ;-) Take a look at NuGetPowerTools. After running Install-Package NuGetPowerTools, it adds a .nuget folder to your $(SolutionDir) containing nuget.exe, nuget msbuild targets and settings (which you will need to check in).

After that, you simply run Enable-PackageRestore and it sets up msbuild targets into your visual studio project files which will make sure that packages will be fetched in a prebuild step, even on your build server, without checking in any packages. (don't forget to check in the .nuget folder though!).

This way, you simply manage the nuget package sources in a nuget msbuild settings file (in the .nuget folder) central to your solution, instead of in each project.

Cheers, Xavier

like image 146
Xavier Decoster Avatar answered Sep 28 '22 08:09

Xavier Decoster