.vsprops文件中的'Delimiter'和'InheritsFromParent'属性是什么意思? [英] What do 'Delimiter' and 'InheritsFromParent' attributes mean in .vsprops files?
问题描述
我似乎找不到Microsoft提供的关于在.vsprops
中定义用户宏时如何使用UserMacro
元素中的Delimiter
和InheritsFromParent
属性的有用的文档. 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 filed.vsprops
('d' for derived) using theInheritedPropertySheets
tag. d.vsprops
includes the property sheet fileb.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:
-
要在用于构建事件的环境中定义用户宏,必须使用
-
PerformEnvironmentSet="true"
.证明:NOENV
未在构建输出中显示. - 用户宏是 ,始终从包含的属性表继承而来,而不管
PerformEnvironmentSet
还是InheritsFromParent
.证明:在b.vsprops
中,未在环境中设置NOENV
,而在d.vsprops
中无需使用InheritsFromParent
即可使用它. - 用户宏的简单重新定义 覆盖 .证明:
OVERRIDE
设置为D
,尽管之前已将其定义为B
.
使用新的
InheritsFromParent="true"
重新定义用户宏,并将其定义为任何先前的定义,并用指定的Delimiter
分隔.证明:PREPEND
设置为D+B
(不是D
或B+D
.)
PerformEnvironmentSet="true"
is necessary for User Macros to be defined in the environment used for build events. Proof:NOENV
not shown in build output.- User Macros are always inherited from included property sheets regardless of
PerformEnvironmentSet
orInheritsFromParent
. Proof: inb.vsprops
,NOENV
is not set in the environment and ind.vsprops
it is used without need ofInheritsFromParent
. - Simple redefinition of a User Macro overrides any previous definition. Proof:
OVERRIDE
is set toD
although it was earlier defined asB
. - Redefinition of a User Macro with
InheritsFromParent="true"
prepends the new definition to any previous definition, separated by a specifiedDelimiter
. Proof:PREPEND
is set toD+B
(notD
orB+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项目系统的第七部分:"makefile"项目和(重新)使用环境
这篇关于.vsprops文件中的'Delimiter'和'InheritsFromParent'属性是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!