gpt4 book ai didi

c++ - 为什么原生 C++ 项目有 TargetFrameworkVersion?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:24:03 24 4
gpt4 key购买 nike

在 Visual Studio(v100、v110)中,可以使用项目文件中的 TargetFrameworkVersion 元素指定项目面向的 .NET Framework 版本。 (如果没有 TargetFrameworkVersion 元素,IDE 仅使用其默认的 .NET 版本。)指定的 TargetFrameworkVersion 然后用于选择将用于构建项目的(默认)工具链。

以上内容适用于 CLR 和 native C++ 项目。我觉得这真的很奇怪和令人困惑。如果 Visual Studio 知道一个项目是原生的,那么它为什么要关心 TargetFrameworkVersion 是什么?

最佳答案

好吧,实际上您必须询问负责创建 MSBuild 的开发人员脚本,因为原则上它不是真正需要的,也不是使用的。他们自己也知道。对于标准 C++ 项目文件,这些是导致设置属性的行 (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>

关于c++ - 为什么原生 C++ 项目有 TargetFrameworkVersion?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21845605/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com