Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when changing to <TargetFrameworks> (plural) in .NET Core csproj file

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?

like image 631
David Avatar asked Sep 17 '19 19:09

David


3 Answers

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

like image 79
farlee2121 Avatar answered Oct 13 '22 22:10

farlee2121


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

like image 3
mbursill Avatar answered Oct 14 '22 00:10

mbursill


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.

like image 1
Shams Wadud Abbir Avatar answered Oct 13 '22 22:10

Shams Wadud Abbir