Install package reference doesn't save csproj.

Jan 21, 2011 at 8:35 PM


I installed a package through the UI in my project, but closed my project without saving and reopened it. Now the console and the UI says different things :

in the UI "Installed package" says there no packages installed for that project but on the console "Get-Package" returns me the package name...

I just find the different results a bit confusing, I guess  its coming from the fact that we don't save csproj but we save packages.config. (it's also hard to tell visually that the csproj was modified after the package installation)

should we auto-save the csproj after installing a package ?


Jan 21, 2011 at 9:02 PM

Didn't VS remind you to save the project when you close it?

The reason the console and dialog says different things is that the Console shows all packages installed in the solution, whereas the dialog shows packages installed in the selected project. In your case, the package has been installed into the solution, but because you didn't save the project, NuGet didn't detect the package in the project.

Jan 21, 2011 at 9:19 PM

>Didn't VS remind you to save the project when you close it?

yes it does, I didn't noticed it the first time as I clicked no automatically. 

Fair enough.

Is there a way to "Get-Package" for a specific project ?

Jan 21, 2011 at 9:38 PM

the Get-Package command itself doesn't offer any way to get packages for a specific project, unfortunately.

if you really want to do that, you can create package manager objects to get to the project's packages. I can show you a sample code if you're interested. :)

Jan 21, 2011 at 10:06 PM

The important point is that if someone makes that mistake, there should be an easy way to get themselves back into a clean state, and I'm not sure we're there yet.  We really need that fix-things-up command that we've been talking about for ages.