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

5

12

How to resolve Visual Studio (MSBuild) error message:

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

Greasewood answered 23/3, 2020 at 15:30 Comment(0)
G
6

The problem was caused by wrong project type specified in .sln file. In the solution file the project had type {D954291E-2A0B-460D-934E-DC6B0785DB48} (Shared Project / Windows Store App Universal).

...
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SomeProject", "SomeProject", "{...}"
...

But actually the project is C# (SDK project). The problem was solved by changing the GUID/UUID in the solution file to the correct one, which is {9A19103F-16F7-4668-BE54-9A1E7A4F7556}.

...
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SomeProject", "SomeProject", "{...}"
...
Greasewood answered 23/3, 2020 at 15:30 Comment(2)
In my case I suspected the solution file got messed up after a bad merge. Rather than try to figure out which of the project/solution item GUIDs were bad, I ended up deleting the solution file, creating a new one from the Blank Solution template in Visual Studio, then rebuilding the solution file by adding the projects back in one at a time. That seemed to fix it.Disaffiliate
This answer clued me into my actual problem which is that the path to the .csproj file is case sensitive and for some reason a couple of the projects had an incorrect lowercase letter in the path, and it only became an error when moving the TargetFramework element from the project files into the Directory.Build.Props filePadriac
B
8

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

This issue can happen with Rider IDE if you haven't also installed Microsoft's Visual Studio, along with relevant add-ons libraries dealing with your project (for example Xamarin).

Installing Rider + .NET Framework + MSbuild may not be enough to resolve the issue.

Perhaps it's obvious but not for everybody, in particular developers new to .NET coding.

Benedetta answered 2/2, 2022 at 13:45 Comment(2)
Installing VS with Xamarin plugins worked for meAlbarran
those who don't have Vexing Studio license may be able to resolve it by obtaining the Xamarin SDK (haven't tried myself)Fabliau
G
6

The problem was caused by wrong project type specified in .sln file. In the solution file the project had type {D954291E-2A0B-460D-934E-DC6B0785DB48} (Shared Project / Windows Store App Universal).

...
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SomeProject", "SomeProject", "{...}"
...

But actually the project is C# (SDK project). The problem was solved by changing the GUID/UUID in the solution file to the correct one, which is {9A19103F-16F7-4668-BE54-9A1E7A4F7556}.

...
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SomeProject", "SomeProject", "{...}"
...
Greasewood answered 23/3, 2020 at 15:30 Comment(2)
In my case I suspected the solution file got messed up after a bad merge. Rather than try to figure out which of the project/solution item GUIDs were bad, I ended up deleting the solution file, creating a new one from the Blank Solution template in Visual Studio, then rebuilding the solution file by adding the projects back in one at a time. That seemed to fix it.Disaffiliate
This answer clued me into my actual problem which is that the path to the .csproj file is case sensitive and for some reason a couple of the projects had an incorrect lowercase letter in the path, and it only became an error when moving the TargetFramework element from the project files into the Directory.Build.Props filePadriac
C
5

This happened for me when my computer crashed while I had a solution open. When I opened it up again, nothing would build. None of the previously mentioned solutions worked. Here's what did:

  1. Close the Visual Studio with the solution
  2. Go to the solution's folder in file explorer
  3. Delete the .vs hidden folder
  4. Open the solution again

I'm using VS 17.

Coastline answered 6/3, 2023 at 16:43 Comment(1)
Deleting the .vs folder did not help in my situation.Lubricate
T
4

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.

Topsoil answered 20/11, 2020 at 11:55 Comment(1)
Thank you. It was a duplicate entry causing this for me.Poul
W
0

In my case the .gitignore file was ignoring the Directory.Build and Directory.Build. The other teammate who left the company has copied the file from and old project.

Warton answered 29/6, 2024 at 16:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.