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

流过昼夜 提交于 2019-12-11 03:35:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/57981214/error-when-changing-to-targetframeworks-plural-in-net-core-csproj-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!