How do I change a property's value based on a conditional in msbuild?

Posted by Noel Kennedy on Stack Overflow See other posts from Stack Overflow or by Noel Kennedy
Published on 2010-06-15T10:55:52Z Indexed on 2010/06/15 11:32 UTC
Read the original article Hit count: 239

Filed under:

I would like to change the value of a property if it is a certain value. In C# I would write:

if(x=="NotAllowed")
  x="CorrectedValue;

This is what I have so far, please don't laugh:

 <PropertyGroup>
    <BranchName>BranchNameNotSet</BranchName>
  </PropertyGroup>

///Other targets set BranchName

 <Target Name="CheckPropertiesHaveBeenSet">
    <Error Condition="$(BranchName)==BranchNameNotSet" Text="Something has gone wrong.. branch name not entered"/>
      <When Condition="$(BranchName)==master">
        <PropertyGroup>
          <BranchName>MasterBranch</BranchName>
        </PropertyGroup>
      </When>
  </Target>

© Stack Overflow or respective owner

Related posts about msbuild