1

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

from Visual Studio

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.

Kirsten
  • 15,730
  • 41
  • 179
  • 318

1 Answers1

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.

Julian
  • 33,915
  • 22
  • 119
  • 174