Build tips of TeamBuild scripts


  • MS Build evaluates the condition of the target first and then do the dependency check. For example, in the mentioned proj file, target "B" will never be invoked.

 <Target Name="A"
Condition="'false'= ='true'"
<Message Text="A"/>

  <Target Name="B">
<Message Text="B"/>

  • Calling msbuild task inside the your proj file will invoke a new process. The child process (of msbuild task) will not inherit all the properties from the parent process. If you want to reuse the properties, you need to explicitly pass them using "Properties" tag of the task.
  • You can split the itemgroups based on attributes using CreateItem task.

<ResxFile Include="dir1\Resources.resx"/>
<ResxFile Include="dir2\Resources.resx">

  <Target Name="SplitResourcesByOutputAttribute">
<CreateItem Include="@(ResxFile)" Condition="'%(ResxFile.OutputResource)'= =''">
<Output TaskParameter="Include" ItemName="ResxFilesWithoutAttribute"/>
<CreateItem Include="@(ResxFile)" Condition="'%(ResxFile.OutputResource)'!=''">
<Output TaskParameter="Include" ItemName="ResxFileWithAttribute"/>