views:

239

answers:

1

Hi,

I've been using Visual Studio's property sheets for building my code and I have a useful hierarchy of sheets controlling the build settings, rather than having them in the vcproj files. This is great except for one thing. I can't seem to set properties in the Project Defaults section such as CharacterType and ConfigurationType.

I tried using a VCConfiguration tool in the vsprops but to no avail:

<Tool
    Name="VCConfiguration"
    ConfigurationType="4"
/>

Can anyone tell me how this is accomplished please?

+1  A: 

That's because the Project Default settings change a bunch of settings, not just one. The CharacterType is the easier one, this .vsprops file changes it to Unicode:

<?xml version="1.0"?>
<VisualStudioPropertySheet
        ProjectType="Visual C++"
        Version="8.00"
        Name="Unicode Support">
        <Tool
                Name="VCCLCompilerTool"
                PreprocessorDefinitions="_UNICODE;UNICODE"/>
        <Tool
                Name="VCResourceCompilerTool"
                PreprocessorDefinitions="_UNICODE;UNICODE"/>
</VisualStudioPropertySheet>

ConfigurationType however changes a lot of them. The best thing to do is to start with a vanilla project template. Save the .vcproj file. Change the ConfigurationType and save again. Run a diff on the two .vcproj files to see what settings you should include in your project property sheet. You'll then also easily see that the ConfigurationType element is actually in the <Configurations/Configuration> section.

Hans Passant
Thanks for the answer, this I understand, however attributes outside a Tool tag in a vsprops are ignored if they appear inside the Project Defaults section. Intermediate and Output directories can be set like this: <VisualStudioPropertySheet ProjectType="Visual C++" Version="8.00" Name="Test" OutputDirectory="..." ConfigurationType="4"> </VisualStudioPropertySheet>In the above example, output directory works but the configuration type is ignored by all projects that inherit directly or indirectly the property sheet.
Cthutu
@Cthutu: yes you're right, the Project Defaults settings don't have the option of selecting "Inherit from parent or project defaults". There's no workaround for that afaik. Still, it is the actual settings that matter, they control how the project is built, not the project defaults.
Hans Passant