'Error occurred while restoring NuGet packages: "Invalid restore input. No target frameworks specified."

How to resolve Visual Studio (MSBuild) error message:

Error occurred while restoring NuGet packages: "Invalid restore input. No target frameworks specified."



Solution 1:[1]

WARNING : It seems that you can't work only with JetBrains Rider IDE without visual studio !

This issue can also be happen with Rider IDE if you don't install alongside the Visual Studio solution of Microsoft with all addons libraries dealing with your project.

Because install Rider + .NET Framework + MSbuild JetBrains no solving the issue.

Perhaps is obvious but not for all in particular new developers of world of .NET coding.

Solution 2:[2]

I had this error recently in a project which builds a NuGet package targeting multiple frameworks.

In brief, I had this in my .csproj file (presumably a git merge error):

<TargetFrameworks>netstandard2.1;net462;net48;net48</TargetFrameworks>

Note the duplicate entry for net48. The odd thing was that it still built on my machine (presumably due to something being cached on disk somewhere). Once I removed the duplicate entry everything started working again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 darkomen
Solution 2 Tom Chantler