如何使用msbuild和设置C++17命令行编译Visual Studio项目?

How to command line compile a Visual Studio project using msbuild and setting C++17?

本文关键字:Visual 编译 Studio 项目 命令行 C++17 何使用 msbuild 设置      更新时间:2023-10-16

我已经制作了一个build.xml文件在我的VS项目中使用,但它需要使用/std:c ++ 17进行编译,我不知道如何将其设置为构建配置xml。

<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<SourceFolder>.</SourceFolder>
</PropertyGroup>
<Target Name="Start">
<CallTarget Targets="Build"></CallTarget>
</Target>
<Target Name = "Build">
<MSBuild 
Projects=".FknUtils.sln"
Properties="Configuration=Release"
Targets="Clean;Build"
ContinueOnError="false"
StopOnFirstFailure="true"/>
</Target>
</Project>

您可以通过右键单击solution explorer中的项目来执行此操作,选择Properties,然后在General分隔符的C++ Language Standard字段中选择ISO C++17 Standard (std:c++17)

这会将选项添加到您的配置文件中<LanguageStandard>stdcpp17</LanguageStandard>.

像这样:

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard> 
<TreatWarningAsError>false</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>