Skip to content

Commit 0cba86c

Browse files
committed
fix: isolate project outputs and prevent file locking during builds
1 parent 86e07f3 commit 0cba86c

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
<!-- Suppress upgrade warning - we're using SDK's built-in analyzers -->
1616
<_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning>
1717
</PropertyGroup>
18+
19+
<PropertyGroup>
20+
<!-- Give each project its own obj directory to avoid cross-project locking -->
21+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(MSBuildProjectDirectory)/obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
22+
</PropertyGroup>
1823
</Project>

src/CycloneDX.MSBuild/CycloneDX.MSBuild.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
</PackageReleaseNotes>
3333
</PropertyGroup>
3434

35+
<PropertyGroup Condition="'$(IsTopLevelBuildProject)' != 'true'">
36+
<!-- When this project is built transitively we isolate its output to avoid file locking -->
37+
<CycloneDXParallelOutputRoot>$(MSBuildProjectDirectory)/bin/$(Configuration)/$(TargetFramework)/_references/$(MSBuildNodeId)/</CycloneDXParallelOutputRoot>
38+
<OutputPath>$(CycloneDXParallelOutputRoot)</OutputPath>
39+
<!-- Skip package generation for dependency builds to prevent repeated pack operations -->
40+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
41+
</PropertyGroup>
42+
3543
<ItemGroup>
3644
<!-- Include build files in package -->
3745
<None Include="build\**" Pack="true" PackagePath="build\" />

tests/CycloneDX.MSBuild.Tests/CycloneDX.MSBuild.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- This prevents parallel builds of the shared dependency that cause file locking -->
3131
<ProjectReference Include="../../src/CycloneDX.MSBuild/CycloneDX.MSBuild.csproj">
3232
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
33+
<BuildInParallel>false</BuildInParallel>
3334
<Properties>GeneratePackageOnBuild=false</Properties>
3435
</ProjectReference>
3536

tests/Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@
1515
<!-- Use project-specific intermediate output directories to prevent parallel build conflicts -->
1616
<!-- This ensures each project has its own obj/ directory even when building shared dependencies -->
1717
<BaseIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
18-
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)/</IntermediateOutputPath>
1918
</PropertyGroup>
2019
</Project>

0 commit comments

Comments
 (0)