locked
Conditional overriding of targets RRS feed

  • Question

  • Hi,

    I have a scenario where based on the value of a property in Team Build I would want to either override a target or use the original target?

    Has anybody worked on conditional overriding before?

    Monday, August 2, 2010 1:27 AM

Answers

  • Hi

    I believe you would need to put the condition on an import, e.g.

    file.proj

    <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Target Name="Default">
        <Message Text="hello from original Default"/>
      </Target>
      <Import Project="ImportOverride.proj" Condition="'$(import)' == 'true'"/>
    </Project>
    
    ImportOverride.proj

     

    <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Target Name="Default">
        <Message Text="hello from imported Default"/>
      </Target>
    </Project>
    
    Mike


    Visual Studio ALM MVP
    My Blog | MSBuild Extension Pack | MSBuild Explorer
    • Proposed as answer by Nancy Shao Tuesday, August 3, 2010 3:30 AM
    • Marked as answer by Nancy Shao Tuesday, August 10, 2010 3:31 AM
    Monday, August 2, 2010 12:49 PM