<?xml version='1.0' encoding='utf-8'?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->


<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <Import Project="WixBuild.props" />
  <Import Project="WixBuild.Tools.targets"/>

  <PropertyGroup>
    <BuildInParallel Condition="'$(BuildInParallel)' == ''">true</BuildInParallel>
  </PropertyGroup>

  <ItemDefinitionGroup>
    <ProjectReference>
      <BuildInParallel>$(BuildInParallel)</BuildInParallel>
    </ProjectReference>
  </ItemDefinitionGroup>

  <Target Name="Build"
          DependsOnTargets="_GroupProjectReferencesByParallelization">
    <MSBuild Projects="@(_NonParallelProjects)" BuildInParallel="false" />
    <MSBuild Projects="@(_ParallelProjects)" BuildInParallel="true" />
  </Target>

  <Target Name="Clean"
          DependsOnTargets="_GroupProjectReferencesByParallelization">
    <MSBuild Projects="@(_ParallelProjects)" Targets="Clean" BuildInParallel="true" />
    <MSBuild Projects="@(_NonParallelProjects)" Targets="Clean" BuildInParallel="false" />
  </Target>

  <Target Name="Rebuild" DependsOnTargets="Clean;Build" />

  <Target Name="_GroupProjectReferencesByParallelization">
    <ItemGroup>
      <_NonParallelProjects Include="@(ProjectReference)" Condition=" '%(BuildInParallel)'!='true' " />
      <_ParallelProjects Include="@(ProjectReference)" Condition=" '%(BuildInParallel)'=='true' " />
    </ItemGroup>
  </Target>

</Project>
