代码之家  ›  专栏  ›  技术社区  ›  c00000fd

如何在VS2017中禁用“警告MSB8051:不推荐针对Windows XP的支持”?

  •  3
  • c00000fd  · 技术社区  · 6 年前

    从Visual Studio 2017的最新更新开始,我在构建MFC项目的过程中开始收到以下警告:

    1>C:\Program Files(x86)\Microsoft Visual 警告MSB8051:不推荐使用针对Windows XP的支持,并且 将不会出现在Visual Studio的未来版本中。请看 https://go.microsoft.com/fwlink/?linkid=2023588

    如何禁用此警告?

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  10
  •   unholytony    6 年前

    将它添加到.vcxproj文件中,或者添加到现有的PropertyGroup中,或者添加到它自己的PropertyGroup中。

    <PropertyGroup>
        <XPDeprecationWarning>false</XPDeprecationWarning>
    </PropertyGroup>
    

    或者通过命令行

    msbuild [project file] /p:XPDeprecationWarning=false
    

    另一种可能是转到“属性管理器”窗口,并在项目中“添加新属性表…”。右键单击新图纸并选择“通用属性”->“用户宏”->“添加宏”,并使用名称XPDeprecationWarning和值false。遗憾的是,您不能仅在项目上执行此操作,因为Visual Studio不允许您使用GUI编辑根项目文件上的UserMacros(我一直想知道为什么文件中有节点)。

        2
  •  1
  •   Steve Friedl decasteljau    5 年前

    对于那些使用单独的属性表(在视图-->其他窗口-->属性管理器中找到)将多个项目的属性合并到单个文件中的人,我的文件在其中 AllCommon.props ,我可以添加替换空值 <PropertyGroup /> 具有

     <PropertyGroup>
       <XPDeprecationWarning>false</XPDeprecationWarning>
     </PropertyGroup>
    

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <ImportGroup Label="PropertySheets" />
      <PropertyGroup Label="UserMacros" />
      <PropertyGroup>
        <XPDeprecationWarning>false</XPDeprecationWarning>
      </PropertyGroup>
      <ItemDefinitionGroup>
        <ClCompile>
          <WarningLevel>Level4</WarningLevel>
          <AdditionalIncludeDirectories>..\MyCommonLibrary</AdditionalIncludeDirectories>
          <CallingConvention>StdCall</CallingConvention>
          <TreatWarningAsError>true</TreatWarningAsError>
        </ClCompile>
      </ItemDefinitionGroup>
      <ItemGroup />
    </Project>
    

    这是可行的,奇怪的是,我不必对用户宏做任何事情。这个文件必须手工编辑,因为我还没有找到用GUI编辑的方法。