MSBuildSdks icon indicating copy to clipboard operation
MSBuildSdks copied to clipboard

Build some projects in parallel with Microsoft.Build.Traversal

Open avivanoff opened this issue 2 years ago • 3 comments

I am building quite a few projects, some of them are dependent on other projects. Because it is a mix of managed and native projects, i cannot always use project references to express dependencies. Is there a way to express this with Microsoft.Build.Traversal, making sure that dependent projects are built in order, while independent are built in parallel?

avivanoff avatar Jun 17 '22 21:06 avivanoff

Microsoft.Build.Traversal does not have any other way to express dependencies at the moment. You should be able to native projects reference managed projects and visa versa. Perhaps we can find a way to get that to work for you?

jeffkl avatar Jun 20 '22 20:06 jeffkl

Here's a related problem. I have this in my dirs.proj:

<ProjectReference Condition="'$(NugetPackagingOnly)' != 'true'" Include="PackageUI\src\LanguagePackage.vcxproj"  SetPlatform="Platform=AnyCPU" />
<ProjectReference Condition="'$(NugetPackagingOnly)' != 'true'" Include="PackageUI\src\LanguagePackage.vcxproj" SetPlatform="Platform=x64" />

Unfortunately there's a build target that lives in a shared package that I don't own which creates a temp file in $(MSBuildProjectDirectory) which is not a happy way to do things.

How can I build the same project twice and guarantee it happens serially?

shueybubbles avatar Oct 07 '22 19:10 shueybubbles

@shueybubbles you should be able to set BuildInParallel=false on the <ProjectReference />:

<Project Sdk="Microsoft.Build.Traversal">
  <ItemGroup>
    <ProjectReference Condition="'$(NugetPackagingOnly)' != 'true'" Include="PackageUI\src\LanguagePackage.vcxproj" SetPlatform="Platform=AnyCPU" BuildInParallel="false" />
    <ProjectReference Condition="'$(NugetPackagingOnly)' != 'true'" Include="PackageUI\src\LanguagePackage.vcxproj" SetPlatform="Platform=x64" BuildInParallel="false" />
  </ItemGroup>
</Project>

jeffkl avatar Oct 10 '22 16:10 jeffkl