Why do native C ++ projects have a TargetFrameworkVersion?

In Visual Studio (v100, v110), you can specify the version of the .NET framework that the project aims to use the TargetFrameworkVersion element in the project file. (If the TargetFrameworkVersion element is missing, the IDE simply uses its default version of .NET.) Then, the specified TargetFrameworkVersion is used to select the tool chain (by default) that will be used to build the project.

The above is true for CLR and for native C ++ projects. I find it really strange and confusing. If Visual Studio knows that the project is native, then why does it care about what TargetFrameworkVersion is?

+2
source share
2 answers

Well, in fact, you will have to ask the developers who are responsible for creating the MSBuild scripts , because in principle this is really not needed and is not used. And they themselves know it. For a standard C ++ project file, these are the lines that cause the property to be set (Microsoft.Common.targets):

  <!-- By default, we are creating a managed app because .NET 2.0 projects did not have this property. -->
  <PropertyGroup Condition="'$(TargetRuntime)' == ''">
    <TargetRuntime>Managed</TargetRuntime>
  </PropertyGroup>

  <!-- Because .NET 2.0 apps did not set TargetFrameworkIdentifier, we need to set it for them here by default. If
       the runtime is set to Managed, we also need to set these.  Otherwise they should be blank (for instance Javascript or
       Native apps) because they do not target a .NET Framework. -->
  <PropertyGroup Condition="'$(TargetRuntime)' == 'Managed'">
    <TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier>
    <TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v4.0</TargetFrameworkVersion>
  </PropertyGroup>
+2
source

Lazy programming, basically. Microsoft has historically preferred managed code because it is not very portable for other operating systems, which causes blocking. Therefore, .NET languages ​​have a higher priority in Visual Studio.

-1
source

All Articles