Tuesday, July 21, 2015

The NuGetPackage package did not load correctly

I just installed Visual Studio 2015 Enterprise RTM and attempted to open an existing Visual Studio 2013 solution that was using a NuGet.config file for NuGet Package Restores and was suddenly faced with this error message:






I found this article which seems to address this issue: http://stackoverflow.com/questions/31521438/vs2015-the-nugetpackage-package-did-not-load-correctly

I followed the steps outlined in the StackOverflow post as suggested by first uninstalling NuGet Package Manager from Visual Studio:


I then reinstalled NuGet Package Manager:






After restarting the IDE, I tried once again to "Manage NuGet packages", but unfortunately, I was not able to perform any NuGet operations whatsoever in the IDE including being able to open the "NuGet Package Manager Console"!

When I created a new project/solution in Visual Studio, as you can probably already guess, NuGet works perfectly!  It just fails to work correctly when opening/loading existing projects/solutions created in earlier versions of Visual Studio such as Visual Studio 2013.

Therefore, I decided to do a bit more investigation into what was different in Visual Studio 2015 vs. Visual Studio 2013 and I discovered this little section in the Visual Studio 2015 solution file:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1


By simply replacing this information in my existing Visual Studio 2013 solution files, I was able to get NuGet Package Manager to work once more!!


However, this victory was short lived since the NuGet problem re-occurred as soon as someone else edited the project file in Visual Studio 2013!  :-(

Well, after doing a bit more digging, I came across this article: http://blog.nuget.org/20150226/nuget-3.0-beta2.html

Based on the directions outlined in the article, I needed to use the old Url for NuGet.org (https://www.nuget.org/api/v2/) to replace the NuGet v. 3.x Url.

Well, I decided to try this as a last ditch effort and sure enough it worked like a charm!!

Woo hoo!!

UPDATE: This article also documents a flaw with the NuGet 3.0 release which requires the Nuget.config file to be checked out from TFS: http://docs.nuget.org/release-notes/nuget-3.0.0

You can download the latest release of NuGet Package Manager for Visual Studio 2015 which should fix this issue from here: https://visualstudiogallery.msdn.microsoft.com/5d345edc-2e2d-4a9c-b73b-d53956dc458d

1 comment: