In the .csproj
file in my .NET Core projects, there are these 3 lines by default:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
Now if I want to target mulitple frameworks, I can change it to this:
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2;net4.6</TargetFrameworks>
</PropertyGroup>
The difference is subtle, but it's there. When targeting multiple frameworks, you have to use <TargetFrameworks>
(plural) instead of just <TargetFramework>
(singular).
But why is it made like this? It seems like it would have been easier to just pick one of the two, and then always use that. Which leads me to the thought, that there might be a more complex reason, for choosing to different (although similar) words, depending on whether or not you target more frameworks. Can anyone enlighten me on the topic?
You can use TargetFrameworks configuration when you are building a class library that will runs well in .Net Full Framework and .Net Core Framework. This is the best use case to this configuration
It doesn't make sense use multiple target framework if you are building a website or webapi. In this case, use just one target framework.