Targetting multiple frameworks does not work (Visual Studio 2022)

Viewed 139

I face an issue with Visual Studio 2022 when I try to target multiple frameworks with the TAG: "multi target" frameworks.

In my .csproj, I change the value for

<TargetFrameworks>net5.0;net45</TargetFrameworks>

and I always get a compilation error.

I try to just add the net45 in the value, but I still get the error.

<TargetFrameworks>net45</TargetFrameworks>

If I let the old value (targeting only one framework)

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

everything works fine and I am able to build my project.

When I use <TargetFrameworks/>, it looks like the compiler tries to use the .NET framework 4.0 to build and not find some reference that was introduced in the 4.5 framework.

CS0117 Task do not contain a definition for 'FromResult'

enter image description here

Any idea what's going on ?

0 Answers
Related