45

I was following a tutorial on Pluralsight about having an MSTest project target both .net core 2.2 AND .NET 4.7.2. This required going to my .csproj file for my test project and editing it so that the following:

 <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    ...

would change to become TargetFrameworks (that's plural now) and then we add in the .NET 4.7.2 moniker, as follows:

 <PropertyGroup>
    <TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks>
    ...

As soon as I saved the .csproj file, VS 2019 showed the following error in a yellow bar at the top:

The project ran into a problem during the last operation: The value of the 'TargetFrameworkMoniker' and 'NuGetTargetMoniker' properties in the 'Debug|AnyCPU' configuration are both empty. This configuration will not contribute to NuGet restore, which may result in restore and build errors.

What am I doing wrong?

Pang
  • 9,564
  • 146
  • 81
  • 122
David
  • 4,665
  • 4
  • 34
  • 60

9 Answers9

45

With Visual Studio closed, removing the .vs folder in the solution root solved it for me.

mbursill
  • 2,911
  • 1
  • 32
  • 44
  • Can confirm this actually solved the error without reinstalling or changing any .NET SDK or Visual studio installation – jaderanderson Mar 09 '23 at 15:15
  • Opening/Closing visual studio or restarting my system didn't worked. But removing the .vs folder and then restarting visual studio worked for me. Thanks. – Rupesh Kamble May 23 '23 at 09:19
42

For me, the error went away when I closed Visual Studio and opened the solution again

farlee2121
  • 2,959
  • 4
  • 29
  • 41
1

I just face this problem for .net core where SDK version was specified as "3.0.103". I just change it to my PC installed .net core version "3.1.300" in global.json file. It worked.

0

After a fair amount of searching, the best answer I could find was this one which is technically for a different error, but talks about having to make the web.config or app.config NOT read-only.

Since I had downloaded a sample solution from an external source, not only did I have read-only files, but my computer had "blocked" the .sln and .csproj files. Once I made all the files non-read-only and "unblocked" the .sln and .csproj files, everything started magically working.

Unblock files

David
  • 4,665
  • 4
  • 34
  • 60
0

Sounds like a silly thing but I fixed this by updating one of my namespace references - previously I had from a previous class and had not updated properly.

  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 15 '22 at 08:08
0

I was stuck with the Error. I eventually solved it by upgrading Visual Studio. I upgraded from 17.3.0 to 17.3.1

Anders Larsen
  • 600
  • 7
  • 13
0

I tried closing out of all VS instances, I was already on the latest version of VS 2022, so I did a repair and restarted my computer and its now working. I'm still not quite sure what was wrong as this solution was working just a few hours earlier and I had changed nothing.

Skint007
  • 195
  • 5
  • 15
0

I too was stuck with the Error. I eventually solved it by upgrading Visual Studio. I upgraded from 17.4.0 to 17.4.2.

¯_(ツ)_/¯

Marc Stevenson
  • 1,090
  • 8
  • 9
-2

I had same problem, It was solved upgrading to the last version of visual studio.