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

时间:2018-12-18 21:38:25

标签: mfc visual-studio-2017

由于是Visual Studio 2017的最新更新之一,因此我在构建MFC项目期间开始收到以下警告:

  

1> C:\ Program Files(x86)\ Microsoft Visual   Studio \ 2017 \ Community \ Common7 \ IDE \ VC \ VCTargets \ Platforms \ x64 \ PlatformToolsets \ v141_xp \ Toolset.targets(39,5):   警告MSB8051:不支持针对Windows XP的支持,并且   在将来的Visual Studio版本中将不存在。请参阅   https://go.microsoft.com/fwlink/?linkid=2023588以获得更多信息。

如何禁用此警告?

这是项目配置:

enter image description here

2 个答案:

答案 0 :(得分:5)

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

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

或通过命令行

msbuild [project file] /p:XPDeprecationWarning=false

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

这些都应该做完全相同的事情,因此,如果其中一个对您不起作用,那么我不确定为什么其他任何一个会更成功。

答案 1 :(得分:0)

对于那些使用单独的属性表(可在View-> Other Windows-> Property Manager中找到)将多个项目的属性组合到一个文件中(我的文件是AllCommon.props)的人,我能够添加替换带有{p>的空<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进行编辑的方法。