Is there a workaround for conditional imports in MSBuild?
I've found evidence here and here detailing a bug in the MSBuild IDE interface. In particular, Import
statements do not reload when building:
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
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?