如何使用 msbuild 和设置 C++17 命令行编译 Visual Studio 项目?
How to command line compile a Visual Studio project using msbuild and setting C++17?
我制作了一个 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
、selecting Properties
和 General
分隔符中的项目来执行此操作,在 [=14] =] 字段 select 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>
我制作了一个 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
、selecting Properties
和 General
分隔符中的项目来执行此操作,在 [=14] =] 字段 select 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>