Visual-studio – NuGet not getting missing packages

nugetnuget-packagevisual studiovisual studio 2010

I have following project structure in VSS

enter image description here

Now in Visual Studio 2010 Pro:
I open Solution2 and then add Library1 as external project.

Library1 is referencing two external libraries which I get via NuGet. When I build my Solution2 it all works fine.
So I checked-in all my project.

Issue:
When another developer gets the Solution2 from sourcesafe and builds, it says Library1 is missing those external libraries dlls.

Tried following:

1: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

So now I have .nuget folder under Solution2 which gets checked-in. But that's still not bringing the dlls.

My doubt is the Library1 being in a separate solution is causing this issue.

Any ideas how to get missing packages automatically via NuGet?

Update:
Xavier's suggestions helped and here are two of his blog posts:

Best Answer

With your current setup, you should make sure you have enabled NuGet Package Restore on both solutions and the Solution2 nuget.targets should point the nuget install command to the Solution1\Packages outputdirectory. Your folder structure will look like this:

Folder structure

Reason: the Library1.csproj references are pointing to the Solution1\Packages location. When adding this project to Solution2, the project references are not changed, but the solution will restore the packages in Solution2\Packages instead of Solution1\Packages.

If you already have installed packages in the projects of Solution2, you'll need to make sure those still restore against Solution2\Packages. To do that, I'd recommend you to set an MSBuild property within the shared project files (above the import statement for the nuget.targets file) and pass this MSBuild property value into the RestoreCommand.

E.g.:

<PackagesOutDir>$(SolutionDir)..\Libraries\Packages</PackagesOutDir>

And adjust the nuget.targets file, e.g.:

<PackagesOutDir Condition="$(PackagesOutDir) == ''">$(SolutionDir)\Packages</PackagesOutDir>

...

<RestoreCommand>... -o "$(PackagesOutDir) "</RestoreCommand>


Optionally, If you want to use a single Packages folder, you could modify both .nuget\NuGet.targets files and set the -o (or -OutputDirectory) switch for the nuget install command.

Appending this to the RestoreCommand element: -o "$(SolutionDir..\Packages" will ensure all packages get restored in a single location:

enter image description here

Note that you will have to manually update the installed package references each time you install a NuGet package after doing this!