Skip to content

Conversation

@dborgards
Copy link
Owner

This fix addresses the build failure during semantic release where the GenerateDepsFile task failed with a file locking error.

Root Cause:

  • Test projects (MultiTargetProject, SimpleProject) have ProjectReferences to CycloneDX.MSBuild
  • When these test projects are built (especially MultiTargetProject with multiple target frameworks), MSBuild builds CycloneDX.MSBuild transitively multiple times in parallel
  • Multiple parallel builds tried to write to the same deps.json file, causing file locking conflicts
  • The existing workaround using $(MSBuildNodeId) for output path isolation was not working correctly in .NET SDK 10.0.100 (variable was resolving to the target framework name instead of a unique node ID)

Solution:

  1. Disable deps.json generation entirely with false
    • The deps.json file is not needed for this project since it's a build tools package with false
  2. Disable SBOM generation for this project with false
    • Prevents the project from trying to analyze itself during build
  3. Remove the broken OutputPath isolation logic
    • MSBuild's default parallel build handling is sufficient now that the problematic file generation is disabled

This allows the project to be built multiple times in parallel without file conflicts.

Fixes: System.IO.IOException: The process cannot access the file 'CycloneDX.MSBuild.deps.json' because it is being used by another process.

This fix addresses the build failure during semantic release where the
GenerateDepsFile task failed with a file locking error.

Root Cause:
- Test projects (MultiTargetProject, SimpleProject) have ProjectReferences
  to CycloneDX.MSBuild
- When these test projects are built (especially MultiTargetProject with
  multiple target frameworks), MSBuild builds CycloneDX.MSBuild transitively
  multiple times in parallel
- Multiple parallel builds tried to write to the same deps.json file,
  causing file locking conflicts
- The existing workaround using $(MSBuildNodeId) for output path isolation
  was not working correctly in .NET SDK 10.0.100 (variable was resolving
  to the target framework name instead of a unique node ID)

Solution:
1. Disable deps.json generation entirely with <GenerateDependencyFile>false
   - The deps.json file is not needed for this project since it's a build
     tools package with <IncludeBuildOutput>false
2. Disable SBOM generation for this project with <GenerateCycloneDxSbom>false
   - Prevents the project from trying to analyze itself during build
3. Remove the broken OutputPath isolation logic
   - MSBuild's default parallel build handling is sufficient now that the
     problematic file generation is disabled

This allows the project to be built multiple times in parallel without
file conflicts.

Fixes: System.IO.IOException: The process cannot access the file
'CycloneDX.MSBuild.deps.json' because it is being used by another process.
@dborgards dborgards requested a review from Copilot December 10, 2025 13:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a file locking issue that occurred during parallel transitive builds when test projects with multiple target frameworks built CycloneDX.MSBuild as a project reference. The solution disables unnecessary file generation (deps.json and SBOM) that was causing the conflicts, and removes the broken OutputPath isolation workaround.

Key Changes:

  • Disabled deps.json generation with <GenerateDependencyFile>false</GenerateDependencyFile>
  • Disabled SBOM generation with <GenerateCycloneDxSbom>false</GenerateCycloneDxSbom>
  • Removed the broken OutputPath isolation logic that relied on $(MSBuildNodeId)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dborgards dborgards merged commit 5409693 into main Dec 10, 2025
10 checks passed
@dborgards dborgards deleted the claude/fix-cyclonedx-build-01Eh3AVVN1anyABSjWouamsG branch December 10, 2025 15:18
@github-actions
Copy link

🎉 This PR is included in version 1.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants