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

问题描述 投票:0回答:1

我已经制作了一个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>

c++ msbuild c++17
1个回答
0
投票

您也可以通过右键单击解决方案资源管理器中的项目,选择PropertiesGeneral分隔符,然后在C++ Langyage 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>
© www.soinside.com 2019 - 2024. All rights reserved.