Thursday, August 29, 2013

MSBuild Choose When Condition


msbuild buildfile.build /target:Deploy /p:Configuration=Release;Environment=Dev
<Choose>
    <When Condition=" '$(Environment)'=='' Or '$(Environment)'=='Dev' ">
      <PropertyGroup>
        <SourceXMLFile>web.dev.config</SourceXMLFile>
        <WebServerName></WebServerName>
        <WebServerUserName></WebServerUserName>
        <WebServerPassword></WebServerPassword>
      </PropertyGroup>
    </When>
    <When Condition=" '$(Environment)'=='Test' ">
      <PropertyGroup>
        <SourceXMLFile>web.test.config</SourceXMLFile>
        <WebServerName></WebServerName>
        <WebServerUserName></WebServerUserName>
        <WebServerPassword></WebServerPassword>
      </PropertyGroup>
    </When>
  </Choose>