我似乎无法从 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
(不是 D
或 B+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/