2016-10-04 4 views
1

Ich versuche, eine XML-Projektdatei zu komprimieren. Das Projekt kompiliert eine einzelne Quelldatei, aber seine Größe ist größer als 11 KB, da die Einstellungen mehrmals kopiert werden. Ich versuche, pro-Quelldatei-Einstellungen zu verschieben und sie in Configuration PropertyGroup mit verschiedenen Bedingung Anweisungen oder Ausdrücke (was nennt sie XML?).VS, die PropertyGroup-Konfigurationseinstellungen nicht berücksichtigt

Wenn ich A guide to .vcxproj and .props file structure von MSDN Blogs richtig bin Parsen, können wir die Einstellungen iin der Eigenschaftsgruppe platzieren:

<PropertyGroup Label=“Configuration“ /> 

    <!– 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... 

Allerdings, wenn ich meine Änderungen überprüfen, indem VS schließen und dann wieder geöffnet es mit dem modifizierten Projektdatei wird keine der Einstellungen übernommen. Visual Studio scheint seine eigenen Einstellungen zu verwenden.

Ich habe ein paar Fragen:

  1. Gibt es eine Visual Studio Einstellung, es zu sagen, jede Einstellung in jeder Quelldatei zu stoppen sraying? Es gibt keinen Grund, eine Einstellung 175x4 Mal für jede Quelldatei zu duplizieren, die in jede Konfiguration übertragen wird.

  2. Verfügt Visual Studio über ein Komprimierungsprogramm, so dass ich dies nicht manuell durchführen muss? Es ist sehr mühsame Arbeit.

  3. Warum erkennt Visual Studio die Einstellungen nicht? Wie repariere ich es?


Hier ist ein Screen-Capture einer Eigenschaftsseite, die Präprozessormakros enthält. Das geänderte XML enthält Folgendes, das in Visual Studio nicht wiedergegeben wird. Ich habe es mit und ohne ClCompile versucht.

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

enter image description here


Hier ist die verdichtete Projektdatei. Die original can be found here. Das Projekt kompiliert 1 Quelldatei und seine Größe über 11 KB wird nicht komprimiert.

Meine Mods beginnen bei <!-- All Configurations --> und enden bei <!-- Back to Visual Studio boilerplate -->. Ich habe noch nicht alle Einstellungen fertiggestellt, aber die, die gemacht wurden, wie Präprozessor-Makros und Laufzeitbibliothek, werden nicht unter Visual Studio angezeigt.

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

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

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

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

    <!-- X86 Configurations --> 
    <PropertyGroup Condition="'$(Platform)'=='Win32'" Label="X86 Configuration"> 
    <ClCompile> 
     <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet> 
    </ClCompile>  
    </PropertyGroup> 

    <!-- X64 Configurations --> 
    <PropertyGroup Condition="'$(Platform)'=='x64'" Label="X64 Configuration"> 
    <ClCompile> 
     <!-- <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet> --> 
     <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet> 
    </ClCompile>  
    </PropertyGroup> 

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

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

Antwort

2

Ihre Einstellungen werden überschrieben, weil Sie sie zu früh in die Datei eingefügt haben. Tun Sie, wie VS tut, und setzen Sie sie nach die <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />.

update mein Fehler; Auf den zweiten Blick haben Ihre Einstellungen keinerlei Auswirkungen, da Sie sie als Eigenschaften definieren. Machen Sie es wie VS tut, und definieren sie in einem ItemDefinitionGroup anstelle eines PropertyGroup (auch hier an der richtigen Stelle gemäß msbuild Bewertungsregeln)

Wie für die Kompaktierung: Speichern Sie Ihre Einstellungen in separaten Eigenschaftsfenster und importieren diese.Wenn Sie dies sinnvoll planen, können Sie die Einstellungen der Projektdatei nie mehr selbst bearbeiten (und daher sind die mit VS bestückten ItemDefinitionGroups leer), aber Sie fügen einfach nur die Eigenschaftenblätter hinzu und entfernen die Projektdatei nur noch als Container für Quell-/Header-Dateien und Eigenschaftenblätter. Wenn Sie den Import in der VS-GUI durchführen ("Property Manager" genannt), werden sie automatisch an der korrekten Position enden, die zuvor erwähnt wurde, und die Reihenfolge ist auch in Ordnung. Sie können auch in VS über den gleichen Optionsdialog wie für das Projekt bearbeitet werden.

Hinweis: Sie können ganze Hierarchien von Eigenschaftsblättern erstellen, die andere importieren, was zur Vermeidung von Wiederholungen nützlich ist. Z.B. Anstatt Ws2_32.lib manuell zu jeder Konfig/Plattform-Combo hinzuzufügen, importieren Sie einfach ein Eigenschaftsblatt, das genau das tut. Besonders praktisch für Bibliotheken, die je nach Plattform/Konfiguration usw. unterschiedliche Namen haben. Und wenn Sie einige Standard-Eigenschaftsblätter für den Compiler/Linker/... erstellt haben, können Sie sie zu einem 'Master' hinzufügen. Beispiel:

enter image description here

+0

Dank @stijn. * "... setze sie nach dem' '... "... - Leider funktioniert das auch nicht. Ich bewege sie weiter, füge '' hinzu und nehme '' weg, < andere Vermutungen >. Sein wirklich unglücklicher Microsoft dokumentiert dieses Zeug nicht richtig. Das wird zur völligen Verschwendung meiner Zeit, seit ich zwei Tage alt bin. Und ich bin nicht näher daran, "EnableEnhancedInstructionSet" richtig einzustellen, so dass X64-Code immer noch langsamer als Win32-Code läuft. – jww

+0

Ich wette Ballmer lacht seinen Arsch auf mich, während er sein Bonusgeld zählt. Ich habe seit 2010 mehr als 3.000 US-Dollar für vier Versionen von Visual Studio-Versionen ausgegeben, um sicherzustellen, dass wir sie richtig unterstützen und ich kann nicht einmal eine anständige Menge an Dokumenten für das Geld bekommen. Stattdessen muss ich zu Stack Overflow kommen und um Antworten betteln. Das ist lächerlich. – jww

+0

erhalten Sie auf BizSpark von Microsoft. Beste 0 Cent, die du (n) jemals ausgegeben hast, um alles zu bekommen – Drew

Verwandte Themen