uninstall-package and removing packages...

May 8, 2011 at 10:09 PM

Please help me out on this one. What is the best approach? I try to give a simplified situation to describe my mental problem.

I have a solution with two projects: P1 and P2. I don't want every project to have a copy of required packages, because I have some base packages that every project will need because it sets up an environment for development.

I added next to my solution a NuGet.config file with the following content:

<settings>
<repositoryPath>packages</repositoryPath>
</settings>

Now all installed packages end up in a folder Packages which is shared by all projects in my solution.

With project  P1 selected I install package X which has an Init.ps1. The packages.config file in my project folder references package X.

Everytime I fire up my solution the Init.ps1 of package X executes, as exepected.

With project  P1 selected I uninstall package X.

Package X is not removed from the Packages folder that is shared by all projects in my solution. The packages.config file in my project folder does not references package X anymore.

Everytime I fire up my solution the Init.ps1 of package X executes, which is not expected!

Shouldn't there be a reference count for packages? If no project references the package it is removed?

May 8, 2011 at 10:19 PM

You should not have to create any NuGet.config file, as the default behavior is to have the Packages folder at solution level. The repositoryPath technique you're using is an experimental/undocumented feature, and may not work well. Please try without it and see how it goes.

May 8, 2011 at 10:34 PM

You saved my day!!!!! It now completely works as expected!

Some questions though:

Q1: is it possible to specify the name of the packages folder?

Q2: is it possible to specify the location of the packages folder, for example outside the tree that goes into source control (in the case we don't want to check in packges into source control)

Q3: is it possible to share packages over multiple solutions? Packages can become big. Let me explain: we want packages with assemblies that can be referenced from projects in solutions when required. For example SharePoint 2010 assemblies (51.7 MB). On a build server we want to pull this set of assemblies in at a known location, so the build server can build even when SharePoint 2010 is not installed on it because it can resolve the project references.

May 9, 2011 at 7:52 PM

No, this is not possible today other than through this undocumented feature. This is tracked by http://nuget.codeplex.com/workitem/215.