Visual studio 将VCProject属性设置为默认值

Visual studio 将VCProject属性设置为默认值,visual-studio,visual-studio-2005,visual-studio-macros,Visual Studio,Visual Studio 2005,Visual Studio Macros,我正在尝试使用一些VS2005 IDE宏来修改解决方案中的大量项目(~80)。我希望设置的一些属性确实将编程接口公开为“默认”,但其他许多属性则不公开。是否有一种通用方法将此类属性设置为默认值?(最终意味着从.vcproj文件中删除它们) 设置一些随机属性的简化示例: Sub SetSomeProps() Dim prj As VCProject Dim cfg As VCConfiguration Dim toolCompiler As VCCLCompilerT

我正在尝试使用一些VS2005 IDE宏来修改解决方案中的大量项目(~80)。我希望设置的一些属性确实将编程接口公开为“默认”,但其他许多属性则不公开。是否有一种通用方法将此类属性设置为默认值?(最终意味着从.vcproj文件中删除它们)

设置一些随机属性的简化示例:

   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

如果您有任何建议,我们将不胜感激。

对于VS2005,我相信您可以在VCConfiguration上使用该方法。下面的代码可以为调用Convention实现这一点(这是C#,但我相信类似的东西也适用于VB):

这与进入GUI并为此选项选择
的效果相同

不幸的是,这在VS 2010中似乎被弃用,我不确定新支持的方法是什么。

对于VS2010,建议您可以将工具对象强制转换为新接口,然后使用其DeleteProperty方法删除该属性。不过,我自己还没试过。
cfg.ClearToolProperty( toolCompiler, "CallingConvention" );