.vsprops文件中的'Delimiter'和'InheritsFromParent'属性是什么意思? [英] What do 'Delimiter' and 'InheritsFromParent' attributes mean in .vsprops files?

查看:141
本文介绍了.vsprops文件中的'Delimiter'和'InheritsFromParent'属性是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到Microsoft提供的关于在.vsprops中定义用户宏时如何使用UserMacro元素中的DelimiterInheritsFromParent属性的有用的文档. Visual Studio的属性表文件.

I can't seem to find any useful documentation from Microsoft about how one would use the Delimiter and InheritsFromParent attributes in the UserMacro element when defining user Macros in .vsprops property sheet files for Visual Studio.

这里是示例用法:

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

从上面的示例中,我猜到"inherit" 的真正含义是"a)如果定义为非空,则追加定界符,并b)追加新定义" 其中,非继承行为将是简单地替换任何当前宏定义.有人有确切消息么?更好的是,没有人对Visual Studio .vsprops文件和宏有任何替代文档的建议来源吗?

From the above example, I'm guessing that "inherit" really means "a) if definition is non-empty then append delimiter, and b) append new definition" where as the non-inherit behavior would be to simply replace any current macro definition. Does anyone know for sure? Even better, does anyone have any suggested source of alternative documentation for Visual Studio .vsprops files and macros?

注意:这与VisualStudioPropertySheet元素的InheritedPropertySheets属性是相同的,例如:

NOTE: this is not the same as the InheritedPropertySheets attribute of the VisualStudioPropertySheet element, for example:

<VisualStudioPropertySheet ... InheritedPropertySheets=".\my.vsprops">

在这种情况下,继承" 基本上表示包含" .

In this case "inherit" basically means "include".

推荐答案

[回答我自己的问题]

InheritsFromParent表示前置.为了验证这一点,我做了一个实验,揭示了用户宏在Visual Studio 2008中的工作方式.这是设置:

InheritsFromParent means prepend. To verify this, I did an experiment that reveals how User Macros work in Visual Studio 2008. Here's the setup:

  • 项目p.vcproj包含使用InheritedPropertySheets标签的属性表文件d.vsprops(对于派生的为'd').
  • d.vsprops包括属性表文件b.vsprops(对于 base ,'b'.)
  • p.vcproj还定义了一个转储环境的预构建事件.
  • 两个.vsprops文件均包含用户宏定义.
  • Project p.vcproj includes the property sheet file d.vsprops ('d' for derived) using the InheritedPropertySheets tag.
  • d.vsprops includes the property sheet file b.vsprops ('b' for base.)
  • p.vcproj also defines a Pre-Build Event which dumps the environment.
  • Both .vsprops files contain User Macro definitions.

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
...

从这些结果中,我们可以得出以下结论:

From these results we can conclude the following:

    要在用于构建事件的环境中定义用户宏,必须使用
  1. PerformEnvironmentSet="true".证明:NOENV未在构建输出中显示.
  2. 用户宏是 ,始终从包含的属性表继承而来,而不管PerformEnvironmentSet还是InheritsFromParent.证明:在b.vsprops中,未在环境中设置NOENV,而在d.vsprops中无需使用InheritsFromParent即可使用它.
  3. 用户宏的简单重新定义 覆盖 .证明:OVERRIDE设置为D,尽管之前已将其定义为B.
  4. 使用新的InheritsFromParent="true" 重新定义用户宏,并将其定义为任何先前的定义,并用指定的Delimiter分隔.证明:PREPEND设置为D+B(不是DB+D.)
  1. PerformEnvironmentSet="true" is necessary for User Macros to be defined in the environment used for build events. Proof: NOENV not shown in build output.
  2. User Macros are always inherited from included property sheets regardless of PerformEnvironmentSet or InheritsFromParent. Proof: in b.vsprops, NOENV is not set in the environment and in d.vsprops it is used without need of InheritsFromParent.
  3. Simple redefinition of a User Macro overrides any previous definition. Proof: OVERRIDE is set to D although it was earlier defined as B.
  4. Redefinition of a User Macro with InheritsFromParent="true" prepends the new definition to any previous definition, separated by a specified Delimiter. Proof: PREPEND is set to D+B (not D or B+D.)

这里有一些其他资源,我可以用来解释Visual Studio .vsprops文件和相关主题,虽然有几年的历史了,但仍然很有帮助:

Here are some additional resources I found for explanation of Visual Studio .vsprops files and related topics, it's from a few years back but it is still helpful:

了解VC项目系统的第一部分:文件和工具

了解VC项目系统第二部分:配置和项目属性页对话框

了解VC项目系统的第三部分:宏,环境变量和共享

了解VC项目系统的第四部分:属性和属性继承

了解VC项目系统的第五部分:构建,工具和依赖项

了解VC项目系统的第六部分:自定义构建步骤和建立事件

了解VC项目系统的第七部分:"makefile"项目和(重新)使用环境

这篇关于.vsprops文件中的'Delimiter'和'InheritsFromParent'属性是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆