VS not honoring PropertyGroup Configuration Settings
<p>I'm trying to compact a XML project file. The project compiles a single source file but its over 11 KB in size because of a penchant for duplicating the same settings multiple times. I'm trying to move per-source-file settings and hoisting them up into Configuration PropertyGroup with different condition statements or expressions (what does XML call them?).</p>

<p>If I am parsing <a href="https://blogs.msdn.microsoft.com/visualstudio/2010/05/14/a-guide-to-vcxproj-and-props-file-structure/" rel="nofollow noreferrer">A guide to .vcxproj and .props file structure</a> from MSDN Blogs correctly, we can place the settings iin the property group:</p>

<pre><code>&lt;PropertyGroup Label=“Configuration“ /&gt;

  &lt;!– This property sheet (directly or via imports) defines the

  default values for many tool-specific properties such as the

  compiler’s Optimization, WarningLevel properties, Midl tool’s

  TypeLibraryName property, etc...
</code></pre>

<p>However, when I check my modifications by closing VS and then re-opening it with the modified project file, none of the settings are picked up. Visual Studio appears to be using its own settings.</p>

<p>I have a few questions:</p>

<ol>
<li><p>Is there a Visual Studio setting to tell it to stop sraying every setting into every source file? There's no reason to duplicate a setting 175x4 times for each source file crossed into each configuration.</p></li>
<li><p>Does Visual Studio have a compaction utility so I don't have to do this by hand? Its very tedious work.</p></li>
<li><p>Why is Visual Studio not picking up the settings? How do I fix it?</p></li>
</ol>

<hr>

<p>Here's a screen capture of a property page which includes Preprocessor Macros. The modified XML has the following, which is not reflected in Visual Studio. I've tried with and without the <code>ClCompile</code>.</p>

<pre><code>&lt;!-- Debug Configurations --&gt;
&lt;PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Release Configuration"&gt;
  &lt;ClCompile&gt;  
    &lt;PreprocessorDefinitions&gt;CRYPTOPP_DLL_ONLY;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
    ...
  &lt;/ClCompile&gt;    
&lt;/PropertyGroup&gt;
</code></pre>

<p><a href="https://i.stack.imgur.com/Ahdpk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ahdpk.png" alt="enter image description here"></a></p>

<hr>

<p>Here's the compacted project file. The <a href="https://github.com/weidai11/cryptopp/blob/master/dlltest.vcxproj" rel="nofollow noreferrer">original can be found here</a>. The project compiles 1 source file, and its over 11KB in size un-compacted.</p>

<p>My mods start at <code>&lt;!-- All Configurations --&gt;</code>, and ends at <code>&lt;!-- Back to Visual Studio boilerplate --&gt;</code>. I have not finished hoisting all the settings, but the ones that have been done, like Preprocessor Macros and Runtime Library, are not reflected under Visual Studio.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  &lt;ItemGroup Label="ProjectConfigurations"&gt;
    &lt;ProjectConfiguration Include="Debug|Win32"&gt;
      &lt;Configuration&gt;Debug&lt;/Configuration&gt;
      &lt;Platform&gt;Win32&lt;/Platform&gt;
    &lt;/ProjectConfiguration&gt;
    &lt;ProjectConfiguration Include="Debug|x64"&gt;
      &lt;Configuration&gt;Debug&lt;/Configuration&gt;
      &lt;Platform&gt;x64&lt;/Platform&gt;
    &lt;/ProjectConfiguration&gt;
    &lt;ProjectConfiguration Include="Release|Win32"&gt;
      &lt;Configuration&gt;Release&lt;/Configuration&gt;
      &lt;Platform&gt;Win32&lt;/Platform&gt;
    &lt;/ProjectConfiguration&gt;
    &lt;ProjectConfiguration Include="Release|x64"&gt;
      &lt;Configuration&gt;Release&lt;/Configuration&gt;
      &lt;Platform&gt;x64&lt;/Platform&gt;
    &lt;/ProjectConfiguration&gt;
  &lt;/ItemGroup&gt;
  &lt;PropertyGroup Label="Globals"&gt;
    &lt;ProjectGuid&gt;{1974a53a-9863-41c9-886d-b2b8c2fc3c8b}&lt;/ProjectGuid&gt;
    &lt;RootNamespace&gt;dlltest&lt;/RootNamespace&gt;
    &lt;PlatformToolset&gt;v100&lt;/PlatformToolset&gt;
  &lt;/PropertyGroup&gt;
  &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /&gt;

  &lt;!-- All Configurations --&gt;
  &lt;PropertyGroup Label="Configuration"&gt;
    &lt;ConfigurationType&gt;Application&lt;/ConfigurationType&gt;
    &lt;UseOfMfc&gt;false&lt;/UseOfMfc&gt;
    &lt;CharacterSet&gt;MultiByte&lt;/CharacterSet&gt;
    &lt;WholeProgramOptimization&gt;true&lt;/WholeProgramOptimization&gt;
    &lt;OutDir&gt;$(Platform)\DLL_Output\$(Configuration)\&lt;/OutDir&gt;
    &lt;IntDir&gt;$(Platform)\$(ProjectName)\$(Configuration)\&lt;/IntDir&gt;
    &lt;ClCompile&gt;
      &lt;WarningLevel&gt;Level4&lt;/WarningLevel&gt;
      &lt;CallingConvention&gt;StdCall&lt;/CallingConvention&gt;
      &lt;SuppressStartupBanner&gt;true&lt;/SuppressStartupBanner&gt;
    &lt;/ClCompile&gt;      
  &lt;/PropertyGroup&gt;

  &lt;!-- Debug Configurations --&gt;
  &lt;PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Debug Configuration"&gt;
    &lt;ClCompile&gt;  
      &lt;PreprocessorDefinitions&gt;CRYPTOPP_DLL_ONLY;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;Optimization&gt;Disabled&lt;/Optimization&gt;
      &lt;BasicRuntimeChecks&gt;EnableFastChecks&lt;/BasicRuntimeChecks&gt;
      &lt;IntrinsicFunctions&gt;true&lt;/IntrinsicFunctions&gt;
      &lt;RuntimeLibrary&gt;MultiThreadedDebug&lt;/RuntimeLibrary&gt;
    &lt;/ClCompile&gt;      
  &lt;/PropertyGroup&gt;

  &lt;!-- Release Configurations --&gt;
  &lt;PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Release Configuration"&gt;
    &lt;ClCompile&gt;
      &lt;PreprocessorDefinitions&gt;NDEBUG;CRYPTOPP_DLL_ONLY;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;OmitFramePointers&gt;true&lt;/OmitFramePointers&gt;
      &lt;IntrinsicFunctions&gt;true&lt;/IntrinsicFunctions&gt;
      &lt;FunctionLevelLinking&gt;true&lt;/FunctionLevelLinking&gt;
      &lt;RuntimeLibrary&gt;MultiThreaded&lt;/RuntimeLibrary&gt;
    &lt;/ClCompile&gt;
  &lt;/PropertyGroup&gt;

  &lt;!-- X86 Configurations --&gt;
  &lt;PropertyGroup Condition="'$(Platform)'=='Win32'" Label="X86 Configuration"&gt;
    &lt;ClCompile&gt;
      &lt;EnableEnhancedInstructionSet&gt;StreamingSIMDExtensions2&lt;/EnableEnhancedInstructionSet&gt;
    &lt;/ClCompile&gt;    
  &lt;/PropertyGroup&gt;

  &lt;!-- X64 Configurations --&gt;
  &lt;PropertyGroup Condition="'$(Platform)'=='x64'" Label="X64 Configuration"&gt;
    &lt;ClCompile&gt;
      &lt;!-- &lt;EnableEnhancedInstructionSet&gt;StreamingSIMDExtensions2&lt;/EnableEnhancedInstructionSet&gt; --&gt;
      &lt;EnableEnhancedInstructionSet&gt;StreamingSIMDExtensions&lt;/EnableEnhancedInstructionSet&gt;
    &lt;/ClCompile&gt;    
  &lt;/PropertyGroup&gt;

  &lt;!-- Back to Visual Studio boilerplate --&gt;
  &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /&gt;
  &lt;ImportGroup Label="ExtensionSettings"&gt;
  &lt;/ImportGroup&gt;
  &lt;ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"&gt;
    &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
  &lt;/ImportGroup&gt;
  &lt;ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"&gt;
    &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
  &lt;/ImportGroup&gt;
  &lt;ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"&gt;
    &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
  &lt;/ImportGroup&gt;
  &lt;ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"&gt;
    &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
  &lt;/ImportGroup&gt;
  &lt;PropertyGroup Label="UserMacros" /&gt;

  &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"&gt;
    &lt;ClCompile&gt;
      &lt;StringPooling&gt;true&lt;/StringPooling&gt;
      &lt;PrecompiledHeader /&gt;
    &lt;/ClCompile&gt;
    &lt;ResourceCompile&gt;
      &lt;PreprocessorDefinitions&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;Culture&gt;0x0409&lt;/Culture&gt;
    &lt;/ResourceCompile&gt;
    &lt;Link&gt;
      &lt;AdditionalDependencies&gt;cryptopp.lib;Ws2_32.lib&lt;/AdditionalDependencies&gt;
      &lt;AdditionalLibraryDirectories&gt;$(Platform)\DLL_Output\$(Configuration)&lt;/AdditionalLibraryDirectories&gt;
      &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
      &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
    &lt;/Link&gt;
  &lt;/ItemDefinitionGroup&gt;
  &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"&gt;
    &lt;ClCompile&gt;
      &lt;StringPooling&gt;true&lt;/StringPooling&gt;
      &lt;PrecompiledHeader /&gt;
    &lt;/ClCompile&gt;
    &lt;ResourceCompile&gt;
      &lt;PreprocessorDefinitions&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;Culture&gt;0x0409&lt;/Culture&gt;
    &lt;/ResourceCompile&gt;
    &lt;Link&gt;
      &lt;AdditionalDependencies&gt;cryptopp.lib;Ws2_32.lib&lt;/AdditionalDependencies&gt;
      &lt;AdditionalLibraryDirectories&gt;$(Platform)\DLL_Output\$(Configuration)&lt;/AdditionalLibraryDirectories&gt;
      &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
      &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
      &lt;TargetMachine&gt;MachineX64&lt;/TargetMachine&gt;
    &lt;/Link&gt;
  &lt;/ItemDefinitionGroup&gt;
  &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"&gt;
    &lt;ClCompile&gt;
      &lt;PrecompiledHeader /&gt;
      &lt;DebugInformationFormat&gt;ProgramDatabase&lt;/DebugInformationFormat&gt;
    &lt;/ClCompile&gt;
    &lt;ResourceCompile&gt;
      &lt;PreprocessorDefinitions&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;Culture&gt;0x0409&lt;/Culture&gt;
    &lt;/ResourceCompile&gt;
    &lt;Link&gt;
      &lt;AdditionalDependencies&gt;cryptopp.lib;Ws2_32.lib&lt;/AdditionalDependencies&gt;
      &lt;AdditionalLibraryDirectories&gt;$(Platform)\DLL_Output\$(Configuration)&lt;/AdditionalLibraryDirectories&gt;
      &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
      &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
    &lt;/Link&gt;
  &lt;/ItemDefinitionGroup&gt;
  &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"&gt;
    &lt;ClCompile&gt;
      &lt;PrecompiledHeader /&gt;
      &lt;DebugInformationFormat&gt;ProgramDatabase&lt;/DebugInformationFormat&gt;
    &lt;/ClCompile&gt;
    &lt;ResourceCompile&gt;
      &lt;PreprocessorDefinitions&gt;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;Culture&gt;0x0409&lt;/Culture&gt;
    &lt;/ResourceCompile&gt;
    &lt;Link&gt;
      &lt;AdditionalDependencies&gt;cryptopp.lib;Ws2_32.lib&lt;/AdditionalDependencies&gt;
      &lt;AdditionalLibraryDirectories&gt;$(Platform)\DLL_Output\$(Configuration)&lt;/AdditionalLibraryDirectories&gt;
      &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
      &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
      &lt;TargetMachine&gt;MachineX64&lt;/TargetMachine&gt;
    &lt;/Link&gt;
  &lt;/ItemDefinitionGroup&gt;
  &lt;ItemGroup&gt;
    &lt;ClCompile Include="dlltest.cpp" /&gt;
  &lt;/ItemGroup&gt;
  &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /&gt;
  &lt;ImportGroup Label="ExtensionTargets"&gt;
  &lt;/ImportGroup&gt;
&lt;/Project&gt;
</code></pre>