As I am currently using some nuget projects which are are altogether about 600MB I wanndered how to set it up to have only one folder of them for every project (in different solutions). I found a way, but it is somehow tricky. Although itWorks!
As the note in information about [NuGetPackageFolderOverride] project says.
There may be dragons. You have been warned!
I am currently using Visual Studio 2012. Though they will be downloaded again for each new project, but you delete them afterwards.
- Create first project i.e [firstProject]
- Install nuget if it is not already installed
http://docs.nuget.org/docs/start-here/installing-nuget - Install your package i.e via PowerShell:
Menu [TOOLS -> NuGet Package Manager -> Package Manager Console]$ Install-Package SharpOVR -Version 0.4.2
- Let it download the packages
– It will emerge in [packages] directory next to the project file [firstProject.sln] - Install nuget package for overriding nuget package folder (if you know what I mean)
$ Install-Package NuGetPackageFolderOverride
- Create the folder in the new path.
– i.e one step up the directory tree: [../_packages/] - Configure the relative path to new package directory via PowerShell
$ Install-NuGetPackageFolderOverride "../_packages/"
- Turn [Visual Studio] off
- Move the package folders from [packages] to new destination [_packages]
– move all but the package [NuGetPackageFolderOverride] folder! - Create new project and repeat the action?
- did not tried yet – I copied the first one
- Copy the [firstProject] files to another destination folder [secondProject]
– It should be already without packages in [packages] folder
– There may be a file [repositories.config] in the [packages] folder- Delete file [secondProject/nuget.config] MANUALLY
– It is quicker manually – you could use command:$ Remove-NuGetPackageFolderOverride
Although you would have to restart the [Visual Studio] afterwards to have it show you the [Restore] button.
– So just delete it manually - Open the [secondProject]
– If you try to build the project it may not see the packages in its default directory [secondProject/packages]Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\SharpDX.2.6.2\build\SharpDX.targets. B:\__DIP\dev\SharpOVR\2015_01_25 2- wiggle 2\RiftGame\RiftGame.csproj 88 5 RiftGame
- Go to [Package Manager Console] and click [Restore]
– Let it download the packages once again - Configure the folder overide once again:
$ Install-NuGetPackageFolderOverride "../_packages/"
- Build the solution
– This is needed step!
– It should build ok – as it builds using [secondProject/packages] packages. - Turn off [Visual Studio]
- Kill Process [MSBuild.exe] via [Windows Task Manager] if it is running
– If you do not kill it, you will have to after trying to delete in the next step as there will be file from one of the folders opened in it. - Delete all [package folders] but the [NuGetPackageFolderOverride] folder from [secondProject/packages]
– There may be a file [repositories.config] in the [packages] folder - Open [secondProject] again
- It should build successfully using packages from [../packages/] folder
- Delete file [secondProject/nuget.config] MANUALLY
Hope it helped!
Consider keeping me awake with more coffee please 😉