MSBuild条件导入 [英] MSBuild Conditional Imports
问题描述
在MSBuild中有条件导入的解决方法吗?
Is there a workaround for conditional imports in MSBuild?
我发现了证据这里和这里详细说明了MSBuild IDE界面中的错误。特别是, Import
语句在构建时不会重新加载:
I've found evidence here and here detailing a bug in the MSBuild IDE interface. In particular, Import
statements do not reload when building:
这是已知的局限性。在加载项目时,VS只会处理一次标记。因此,在项目首次加载时(根据您的属性当时具有的任何值)活动的任何标记都是活动的...这是您将在IDE中为该项目的生命周期获得的标记
This is a known limitation. VS will only ever process the tags once, when the project is loaded. So whatever tag is active at the time the project is first loaded (based on whatever values your properties have at that time)... that's the tag that you will get for the lifetime of that project in the IDE
例如,我可能想要导入栏
或 baz
项目基于 foo的价值
:
For example, I might want to import the bar
or baz
project based on the value of foo
:
<Import Project="bar.targets" Condition="'$(foo)' == 'bar'" />
<Import Project="baz.targets" Condition="'$(foo)' == 'baz'" />
我是否可以使用变通方法或不同的方法来实现所需的功能?
Is there a workaround or different approach I can use for accomplishing the desired functionality?
推荐答案
我认为你不能使用条件导入机制来克服这个问题。你真的想要完成什么?
I don't think that you can overcome this using the conditional import mechaism. What are you really trying to accomplish?
Sayed Ibrahim Hashimi
Sayed Ibrahim Hashimi
我的书: Microsoft Build Engine内部:使用MSBuild和Team Foundation Build
这篇关于MSBuild条件导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!