Opening project in Visual Studio fails due to nuget.targets not found error

So I downloaded Twitterizer from http://www.twitterizer.net/downloads/

I try to open it in Visual Studio and get all these nuget errors:

The imported project "C:\Twitterizer\.nuget\nuget.targets" was not found. 
Confirm that the path in the <Import> declaration is correct, and that the file 
exists on disk.

What is going on. How do I deal with this?


Solution 1:

  1. Install Nuget.
  2. Right click on the solution and select "Enable NuGet Package Restore". In Visual Studio 2013 and later, select "Restore NuGet Packages" instead.
  3. Click Ok on the warning.
  4. Close and re-open the solution.

Should now be hunky-dory.

Solution 2:

An alternative is to edit the .csproj file with a texteditor and remove or comment out the segment.

Solution 3:

This error normally happens when you are trying to open a .csproj directly, not through the solution file, and the .csproj imports the Nuget targets like this:

<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />

In order to solve it, you can either open the .sln and not the .csproj directly...or remove the import line above.

Notice that the mentioned error will only happen when you are using solution wise package restore, which isn't even recommended anymore.