Problem opening from TFS with NuGet Package Restore

Apr 18, 2012 at 5:22 PM
Edited Apr 18, 2012 at 5:26 PM

Hi I hope somebody can help.

I have a solution in TFS 2010.  The solution has several projects with NuGet references to things like Moq, Log4net etc.  And we are using NuGet Package Restore, so not checking the package folder into source control.

So on to my issue.  When I try to open the solution from scratch (ie NO CODE EXISTS ON THE LOCAL HARD DRIVE!) using the menu File -> Source Control -> Open From Source Control...   it fails to load all of the projects which have references installed from NuGet.  The actual error is as follows:

One or more projects in the solution were not loaded correctly.  Please see the Output Window for details.

And then in the Output Window I have an entry like this for every project with NuGet references:

C:\TFSProjects\Test\ExceptionManagement\ExceptionManagement.csproj : error  : Unable to read the project file 'ExceptionManagement.csproj'. 

C:\TFSProjects\Test\ExceptionManagement\ExceptionManagement.csproj(189,3): The imported project "C:\TFSProjects\Test\.nuget\nuget.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Has anyone come across this issue?

Apr 18, 2012 at 5:39 PM

did you check in the .nuget folder under the solution root?

Apr 18, 2012 at 5:42 PM

Hi thanks for replying.  Yes I did check-in the .nuget folder plus the 3 files inside...

Apr 18, 2012 at 5:45 PM

do you see the .targets file here: C:\TFSProjects\Test\.nuget\nuget.targets?

Apr 18, 2012 at 5:47 PM

Yes that file has been pulled down from TFS

Apr 18, 2012 at 5:52 PM

That's strange. Have you tried closing the solution and reloading it?

Apr 19, 2012 at 9:25 AM

Yes I tried that.  The solution opens correctly and I don't get any project load issues, BUT the contents of the project are not downloaded from source control, presumably because the project file wasn't opened correctly first time it was requested from TFS.  This of course can be resolved by manually forcing a GetLatest on the offending projects but this is a pain.

It is quite a large team here and I'm trying to get them to buy in to the benefits of using NuGet but it's hard to convince them to change their current way of working (checking dll's in with each project, urrrgh) if the NuGet process isn't smooth.  I hope we can resolve this!

Apr 19, 2012 at 11:33 PM

I don't know what happened on your environment, but according to my local test here, when I open a solution directly from source control, VS is smart enough to download the .targets file first before opening the project. I am not seeing any project loading issue. Feed free to file a bug with a detailed repro steps.

Apr 20, 2012 at 9:12 AM
Edited Apr 20, 2012 at 9:12 AM

Ah.  I got some colleagues of mine to try just to make sure it wasn't something wrong with my dev environment.  I got 3 other guys to try, on different projects, and across different project collections.  All had the same issue.

Did you have absolutely nothing from the project on your local drive when you tried it?  And you used the "Open from Source Control" menu?

If I manually get the .targets directly from source control before doing the "Open from Source Control" it's fine.  So certainly looks like a timing/ordering problem.

I'll start writing up a full detailed repro.

Apr 20, 2012 at 12:47 PM

Hi I raised an issue, work item #2131

It has got full repro steps, hopefully you can reproduce it!