visual-studio - .vsprops 文件中的 'Delimiter' 和 'InheritsFromParent' 属性是什么意思?

标签 visual-studio visual-studio-2008 visual-studio-2005

我似乎无法从 Microsoft 找到任何关于如何使用 Delimiter 的有用文档。和 InheritsFromParent UserMacro 中的属性在 .vsprops 中定义用户宏时的元素Visual Studio 的属性表文件。

这是示例用法:

<UserMacro Name="INCLUDEPATH" Value="$(VCROOT)\Inc"
    InheritsFromParent="TRUE" Delimiter=";"/>

从上面的例子中,我猜测“继承”真的意味着“a)如果定义为非空,则附加分隔符,并且b)附加新定义”,其中非继承行为将简单地替换任何当前的宏定义。有人有确切消息么?更好的是,是否有人有任何建议的 Visual Studio 替代文档来源 .vsprops文件和宏?

注意:这与 InheritedPropertySheets 不同VisualStudioPropertySheet 的属性元素,例如:
<VisualStudioPropertySheet ... InheritedPropertySheets=".\my.vsprops">

在这种情况下,“继承”基本上意味着“包含”。

最佳答案

[回答我自己的问题]
InheritsFromParent意味着预先。为了验证这一点,我做了一个实验来揭示用户宏在 Visual Studio 2008 中的工作方式。这是设置:

  • 项目p.vcproj包括属性表文件 d.vsprops ('d' 表示派生)使用 InheritedPropertySheets标签。
  • d.vsprops包括属性表文件 b.vsprops ('b' 表示基数。)
  • p.vcproj还定义了一个转储环境的预构建事件。
  • 两者 .vsprops文件包含用户宏定义。

  • b.vsprops
    ...
    <UserMacro Name="NOENV" Value="B"/>
    <UserMacro Name="OVERRIDE" Value="B" PerformEnvironmentSet="true"/>
    <UserMacro Name="PREPEND" Value="B" PerformEnvironmentSet="true"/>
    ...
    

    d.vsprops
    ...
    <VisualStudioPropertySheet ... InheritedPropertySheets=".\b.vsprops">
    <UserMacro Name="ENV" Value="$(NOENV)" PerformEnvironmentSet="true"/>
    <UserMacro Name="OVERRIDE" Value="D" PerformEnvironmentSet="true"/>
    <UserMacro Name="PREPEND" Value="D" InheritsFromParent="true"
        Delimiter="+" PerformEnvironmentSet="true"/>
    ...
    

    p.vcproj
    ...
    <Configuration ... InheritedPropertySheets=".\d.vsprops">
    <Tool Name="VCPreBuildEventTool" CommandLine="set | sort"/>
    ...
    

    构建输出
    ...
    ENV=B
    OVERRIDE=D
    PREPEND=D+B
    ...
    

    根据这些结果,我们可以得出以下结论:
  • PerformEnvironmentSet="true"在用于构建事件的环境中定义用户宏是必要的。证明:NOENV未显示在构建输出中。
  • 用户宏是 总是 无论 PerformEnvironmentSet 如何从包含的属性表继承或 InheritsFromParent .证明:在b.vsprops , NOENV未在环境和 d.vsprops 中设置无需InheritsFromParent即可使用.
  • 用户宏的简单重新定义 覆盖 任何先前的定义。证明:OVERRIDE设置为 D尽管它早先被定义为 B .
  • 使用 InheritsFromParent="true" 重新定义用户宏前置 任何先前定义的新定义,由指定的 Delimiter 分隔.证明:PREPEND设置为 D+B (不是 DB+D。)

  • 以下是我找到的一些额外资源,用于解释 Visual Studio .vsprops文件和相关主题,它是几年前的,但它仍然有帮助:

    understanding the VC project system part I: files and tools

    understanding the VC project system part II: configurations and the project property pages dialog

    understanding the VC project system part III: macros, environment variables and sharing

    understanding the VC project system part IV: properties and property inheritance

    understanding the VC project system part V: building, tools and dependencies

    understanding the VC project system part VI: custom build steps and build events

    understanding the VC project system part VII: "makefile" projects and (re-)using environments

    关于visual-studio - .vsprops 文件中的 'Delimiter' 和 'InheritsFromParent' 属性是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/142708/

    相关文章:

    c++ - 由于堆分配/解除分配导致堆栈溢出

    c++ - 我怎样才能让我的非常大的程序链接起来?

    visual-studio - 将 visual studio 升级到 sp1

    c++ - Visual Studio:看窗口:C++:为什么对char类型成员进行垃圾处理?

    vb.net - 在 vb.net 中显示加载屏幕

    visual-studio-2008 - Visual Studio 风格?

    c# - 如何在 Visual Studio 中查找对给定类型变量的所有引用?

    c++ - ISO C 中数组的左值到右值转换

    visual-c++ - 链接到所有 Visual Studio $ 变量

    c++ - 如何在非 MFC 项目中使用 TRACE 宏?