1

我正在尝试一些 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

任何意见,将不胜感激。

4

1 回答 1

2

对于 VS 2005,我相信你可以在 VCConfiguration 上使用ClearToolProperty方法。以下代码将为 CallingConvention 完成此操作(这是 C#,但我确信类似的东西适用于 VB):

cfg.ClearToolProperty( toolCompiler, "CallingConvention" );

这与进入 GUI 并选择"<inherit from parent or project defaults>"此选项具有相同的效果。

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

于 2010-04-30T22:34:38.207 回答