Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable "warning MSB8051: Support for targeting Windows XP is deprecated" in VS2017?

Since about one of the latest updates to Visual Studio 2017 I started getting the following warning during the build of my MFC project:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets\v141_xp\Toolset.targets(39,5): warning MSB8051: Support for targeting Windows XP is deprecated and will not be present in future releases of Visual Studio. Please see https://go.microsoft.com/fwlink/?linkid=2023588 for more information.

How do I disable this warning?

Here's the project configuration:

enter image description here

like image 981
c00000fd Avatar asked Dec 18 '18 21:12

c00000fd


2 Answers

Add this to your .vcxproj file either into an existing PropertyGroup or one of its own.

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

or via command line

msbuild [project file] /p:XPDeprecationWarning=false

Another possibility is to go to your Property Manager window and "Add a new property sheet..." to your project. Right click on the new sheet and select "common Properties"->"User Macros"->"Add Macro" and use the name XPDeprecationWarning and a value of false. Sadly you can't just do this on your project as Visual Studio doesnt allow you to use the GUI to edit UserMacros on the root project file (I have always wondered why as the node is there in the file ).

These should all do exactly the same thing so if one is not working for you then I'm not sure why any of the others would be any more successful.

like image 153
unholytony Avatar answered Sep 20 '22 08:09

unholytony


For those using separate property sheets (found in View --> Other Windows --> Property Manager) to combine properties from multiple projects into a single file, where mine is AllCommon.props, I was able to add replace a null <PropertyGroup /> with

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

So the whole property file now looks like:

<?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>

This works, and I curiously didn't have to do anything with User Macros. This file has to be edited by hand, as I have not found a way to do it with the GUI.

like image 22
Steve Friedl Avatar answered Sep 19 '22 08:09

Steve Friedl