Target V4.7.2 and netcoreapp3.1 in same project. Value does not fall witnin the expected range

隐身守侯 提交于 2020-07-03 11:51:46

问题


I want my Framework 4.7.2 code to use a library that targets netcoreapp3.1 Nuget indicates that the library is referenced, yet I do not see it in the list of references.

I tried editing the project to change the TargetFrameworkVersion from

<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>

to

<TargetFrameworkVersion>v4.7.2;netcoreapp3.1</TargetFrameworkVersion>

But saving this change causes a message

And I cannot re-load the project

I tried chainging to

<TargetFrameworkVersion>netcoreapp3.1;net472</TargetFrameworkVersion>

The build error becomes

Error       The expression "[Microsoft.Build.Utilities.ToolLocationHelper]::
GetPathToStandardLibraries(.NETFramework, netcoreapp3.1;net472, '', '', '', '')" 
cannot be evaluated. Input string was not in a correct format.              

I asked a related question to try and troubleshoot this.


回答1:


I think your looking for <TargetFrameworks>

so in this case:

<TargetFrameworks>netcoreapp3.1;net472</TargetFrameworks>

Please note you need a SDK-style csproj. I assume this in the case for you. If not, check How to upgrade csproj files with VS2017

See also the article about <TargetFrameworkVersion>:

This article shows the old way to specify a target framework. SDK-style projects enable different TargetFrameworks like netstandard. For more info, see Target frameworks.



来源:https://stackoverflow.com/questions/62251125/target-v4-7-2-and-netcoreapp3-1-in-same-project-value-does-not-fall-witnin-the

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