views:

59

answers:

1

I'm trying some VS2005 IDE macros to modify a large amount of projects (~80) within a solution. Some of the properties I wish to set do expose a programmatic interface to 'default', but many others do not. Is there a generic way to set such properties to their default? (eventually meaning erasing them from the .vcproj file)

Simplified example, setting some random properties:

   Sub SetSomeProps()
    Dim prj As VCProject
    Dim cfg As VCConfiguration
    Dim toolCompiler As VCCLCompilerTool
    Dim toolLinker As VCLinkerTool
    Dim EnvPrj As EnvDTE.Project

    For Each EnvPrj In DTE.Solution.Projects
        prj = EnvPrj.Object
        cfg = prj.Configurations.Item(1)


        toolLinker = cfg.Tools("VCLinkerTool")

        If toolLinker IsNot Nothing Then
            ' Some tool props that expose a *default* interface'
            toolLinker.EnableCOMDATFolding = optFoldingType.optFoldingDefault
            toolLinker.OptimizeReferences = optRefType.optReferencesDefault
            toolLinker.OptimizeForWindows98 = optWin98Type.optWin98Default
        End If

        toolCompiler = cfg.Tools("VCCLCompilerTool")

        If toolCompiler IsNot Nothing Then
            ' How to set it to default?  (*erase* the property from the .vcproj)'
            toolCompiler.CallingConvention = callingConventionOption.callConventionCDecl
            toolCompiler.WholeProgramOptimization = False
            toolCompiler.Detect64BitPortabilityProblems = False
        End If

    Next

End Sub

Any advice would be appreciated.

+1  A: 

For VS 2005, I believe you can use the ClearToolProperty method on VCConfiguration. The following code would accomplish this for CallingConvention (this is C#, but I'm sure something similar works for VB):

cfg.ClearToolProperty( toolCompiler, "CallingConvention" );

This would have the same effect as going into the GUI and choosing "<inherit from parent or project defaults>" for this option.

Unfortunately this seems to be deprecated in VS 2010, and I'm not sure what the new supported method is.

Charlie