AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Check Bin Obj Clash

skill-dotnet-skills-check-bin-obj-clash · by dotnet

Detects MSBuild projects with conflicting OutputPath or IntermediateOutputPath. USE FOR: builds failing with 'Cannot create a file when that file already exists', 'The process cannot access the file because it is being used by another process', intermittent build failures that succeed on retry, missing outputs in multi-project builds, multi-targeting builds where project.assets.json conflicts. Di…

No reviews yet
0 installs
5 views
0.0% view→install

Install

$ agentstack add skill-dotnet-skills-check-bin-obj-clash

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-dotnet-skills-check-bin-obj-clash)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
1mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Check Bin Obj Clash? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Detecting OutputPath and IntermediateOutputPath Clashes

Overview

This skill helps identify when multiple MSBuild project evaluations share the same OutputPath or IntermediateOutputPath. This is a common source of build failures including:

  • File access conflicts during parallel builds
  • Missing or overwritten output files
  • Intermittent build failures
  • "File in use" errors
  • NuGet restore errors like Cannot create a file when that file already exists - this strongly indicates multiple projects share the same IntermediateOutputPath where project.assets.json is written

Clashes can occur between:

  • Different projects sharing the same output directory
  • Multi-targeting builds (e.g., TargetFrameworks=net8.0;net9.0) where the path doesn't include the target framework
  • Multiple solution builds where the same project is built from different solutions in a single build

Note: Project instances with BuildProjectReferences=false should be ignored when analyzing clashes - these are P2P reference resolution builds that only query metadata (via GetTargetPath) and do not actually write to output directories.

When to Use This Skill

Invoke this skill immediately when you see:

  • Cannot create a file when that file already exists during NuGet restore
  • The process cannot access the file because it is being used by another process
  • Intermittent build failures that succeed on retry
  • Missing output files or unexpected overwriting

Step 1: Generate a Binary Log

Use the binlog-generation skill to generate a binary log with the correct naming convention.

Primary workflow — binlog MCP

The MCP server exposes structured tools for inspecting a .binlog without parsing text logs. Call them directly instead of replaying the binlog to a text file. Call tools/list for the MCP first if you are unsure which tools are available.

Important constraints:

  • The .binlog file is a binary format — do NOT try to cat, head, strings, or read it directly. Use only the MCP tools to query it.
  • Synthesize findings as you go. Do not spend all available time investigating — once you have enough evidence, present your conclusions.

Step 2: Get an overview and list projects

Use the MCP overview and projects tools to understand the build and list all projects that participated.

Step 3: Check evaluations and global properties

Use the MCP evaluations and evaluation_global_properties tools to find all evaluations per project. Look for:

  • Multiple evaluations for the same project (indicates multi-targeting or multiple build configurations)
  • Differing global properties between evaluations (TargetFramework, Configuration, RuntimeIdentifier, SolutionFileName, PublishReadyToRun, etc.)

Step 4: Get output paths for each evaluation

Use the MCP properties tool to query OutputPath, IntermediateOutputPath, BaseOutputPath, and BaseIntermediateOutputPath for each project evaluation.

Step 5: Check for double writes

Use the MCP double_writes tool if available — it directly detects files written by multiple project instances.

Step 6: Identify clashes

Compare the OutputPath and IntermediateOutputPath values across all evaluations:

  1. Normalize paths - Convert to absolute paths and normalize separators
  2. Group by path - Find evaluations that share the same OutputPath or IntermediateOutputPath
  3. Filter out non-build evaluations - Exclude BuildProjectReferences=false instances (P2P queries)
  4. Report clashes - Any group with more than one evaluation indicates a clash

Fallback workflow — text-log replay (when MCP is unavailable)

Use this only when the MCP server cannot be started.

Step 2: Replay the Binary Log to Text

dotnet msbuild build.binlog -noconlog -fl -flp:v=diag;logfile=full.log

Step 3: List All Projects

grep -i 'done building project\|Building project' full.log | grep -oP '"[^"]+\.csproj"' | sort -u

This lists all project files that participated in the build.

Step 4: Check for Multiple Evaluations per Project

Multiple evaluations for the same project indicate multi-targeting or multiple build configurations:

# Count how many times each project was evaluated
grep -c 'Evaluation started' full.log
grep 'Evaluation started.*\.csproj' full.log

Step 5: Check Global Properties for Each Evaluation

For each project, query the build properties to understand the build configuration:

# Search the diagnostic log for evaluated property values
grep -i 'TargetFramework\|Configuration\|Platform\|RuntimeIdentifier' full.log | head -40

Look for properties like TargetFramework, Configuration, Platform, and RuntimeIdentifier that should differentiate output paths.

Also check solution-related properties to identify multi-solution builds:

  • SolutionFileName, SolutionName, SolutionPath, SolutionDir, SolutionExt — differ when a project is built from multiple solutions
  • CurrentSolutionConfigurationContents — the number of project entries reveals which solution an evaluation belongs to (e.g., 1 project vs ~49 projects)

Look for extra global properties that don't affect output paths but create distinct MSBuild project instances:

  • PublishReadyToRun — a publish setting that doesn't change OutputPath or IntermediateOutputPath, but MSBuild treats it as a distinct project instance, preventing result caching and causing redundant target execution (e.g., CopyFilesToOutputDirectory running again)
  • Any other global property that differs between evaluations but doesn't contribute to path differentiation

Filter Out Non-Build Evaluations

When analyzing clashes, filter evaluations based on the type of clash you're investigating:

  1. For OutputPath clashes: Exclude restore-phase evaluations (where MSBuildRestoreSessionId global property is set). These don't write to output directories.
  1. For IntermediateOutputPath clashes: Include restore-phase evaluations, as NuGet restore writes project.assets.json to the intermediate output path.
  1. Always exclude BuildProjectReferences=false: These are P2P metadata queries, not actual builds that write files.

Step 6: Get Output Paths for Each Project

Query each project's output path properties:

# From the diagnostic log - search for OutputPath assignments
grep -i 'OutputPath\s*=\|IntermediateOutputPath\s*=\|BaseOutputPath\s*=\|BaseIntermediateOutputPath\s*=' full.log | head -40

# Or query a specific project directly
dotnet msbuild MyProject.csproj -getProperty:OutputPath
dotnet msbuild MyProject.csproj -getProperty:IntermediateOutputPath
dotnet msbuild MyProject.csproj -getProperty:BaseOutputPath
dotnet msbuild MyProject.csproj -getProperty:BaseIntermediateOutputPath

Step 7: Identify Clashes

Compare the OutputPath and IntermediateOutputPath values across all evaluations:

  1. Normalize paths - Convert to absolute paths and normalize separators
  2. Group by path - Find evaluations that share the same OutputPath or IntermediateOutputPath
  3. Report clashes - Any group with more than one evaluation indicates a clash

Step 8: Verify Clashes via CopyFilesToOutputDirectory (Optional)

As additional evidence for OutputPath clashes, check if multiple project builds execute the CopyFilesToOutputDirectory target to the same path. Note that not all clashes manifest here - compilation outputs and other targets may also conflict.

# Search for CopyFilesToOutputDirectory target execution per project
grep 'Target "CopyFilesToOutputDirectory"' full.log

# Look for Copy task messages showing file destinations
grep 'Copying file from\|SkipUnchangedFiles' full.log | head -30

Look for evidence of clashes in the messages:

  • Copying file from "..." to "..." - Active file writes
  • Did not copy from file "..." to file "..." because the "SkipUnchangedFiles" parameter was set to "true" - Indicates a second build attempted to write to the same location

The SkipUnchangedFiles skip message often masks clashes - the build succeeds but is vulnerable to race conditions in parallel builds.

Step 9: Check CoreCompile Execution Patterns (Optional)

To understand which project instance did the actual compilation vs redundant work, check CoreCompile:

grep 'Target "CoreCompile"' full.log

Compare the durations:

  • The instance with a long CoreCompile duration (e.g., seconds) is the primary build that did the actual compilation
  • Instances where CoreCompile was skipped (duration ~0-10ms) are redundant builds — they didn't recompile but may still run other targets like CopyFilesToOutputDirectory that write to the same output directory

This helps distinguish the "real" build from redundant instances created by extra global properties or multi-solution builds.

Caveat: Multi-Solution Builds

When analyzing multi-solution builds, note that the diagnostic log interleaves output from all projects. To determine which solution a project instance belongs to, search for SolutionFileName property assignments in the diagnostic log:

grep -i "SolutionFileName\|CurrentSolutionConfigurationContents" full.log | head -20

Expected Output Structure

For each evaluation, collect:

  • Project file path
  • Evaluation ID
  • TargetFramework (if multi-targeting)
  • Configuration
  • OutputPath
  • IntermediateOutputPath

Clash Detection Logic

For each unique OutputPath:
  - If multiple evaluations share it → CLASH
  
For each unique IntermediateOutputPath:
  - If multiple evaluations share it → CLASH

Common Causes and Fixes

Multi-targeting without TargetFramework in path

Problem: Project uses TargetFrameworks but OutputPath doesn't vary by framework.


bin\$(Configuration)\

Fix: Include TargetFramework in the path:


bin\$(Configuration)\$(TargetFramework)\

Or rely on SDK defaults which handle this automatically:

true
true

Shared output directory across projects (CANNOT be fixed with AppendTargetFramework)

Problem: Multiple projects explicitly set the same BaseOutputPath or BaseIntermediateOutputPath.


..\SharedOutput\
..\SharedObj\

..\SharedOutput\
..\SharedObj\

IMPORTANT: Even with AppendTargetFrameworkToOutputPath=true, this will still clash! .NET writes certain files directly to the IntermediateOutputPath without the TargetFramework suffix, including:

  • project.assets.json (NuGet restore output)
  • Other NuGet-related files

This causes errors like Cannot create a file when that file already exists during parallel restore.

Fix: Each project MUST have a unique BaseIntermediateOutputPath. Do not share intermediate output directories across projects:


..\obj\ProjectA\

..\obj\ProjectB\

Or simply use the SDK defaults which place obj inside each project's directory.

RuntimeIdentifier builds clashing

Problem: Building for multiple RIDs without RID in path.

Fix: Ensure RuntimeIdentifier is in the path:

true

Multiple solutions building the same project

Problem: A single build invokes multiple solutions (e.g., via MSBuild task or command line) that include the same project. Each solution build evaluates and builds the project independently, with different Solution* global properties that don't affect the output path.

How to detect: Compare SolutionFileName and CurrentSolutionConfigurationContents across evaluations for the same project. Different values indicate multi-solution builds. For example:

| Property | Eval from Solution A | Eval from Solution B | |---|---|---| | SolutionFileName | BuildAnalyzers.sln | Main.slnx | | CurrentSolutionConfigurationContents | 1 project entry | ~49 project entries | | OutputPath | bin\Release\netstandard2.0\ | bin\Release\netstandard2.0\clash |

Example: A repo build script builds BuildAnalyzers.sln then Main.slnx, and both solutions include SharedAnalyzers.csproj. Both builds write to bin\Release\netstandard2.0\. The first build compiles; the second skips compilation but still runs CopyFilesToOutputDirectory.

Fix: Options include:

  1. Consolidate solutions - Ensure each project is only built from one solution in a single build
  2. Use different configurations - Build solutions with different Configuration values that result in different output paths
  3. Exclude duplicate projects - Use solution filters or conditional project inclusion to avoid building the same project twice

Extra global properties creating redundant project instances

Problem: A project is built multiple times within the same solution due to extra global properties (e.g., PublishReadyToRun=false) that create distinct MSBuild project instances. These properties don't affect output paths but prevent MSBuild from caching results across instances, causing redundant target execution.

How to detect: Compare global properties across evaluations for the same project within the same solution (same SolutionFileName). Look for properties that differ but don't contribute to path differentiation:

| Property | Eval A (from Razor.slnx) | Eval B (from Razor.slnx) | |---|---|---| | PublishReadyToRun | (not set) | false | | OutputPath | bin\Release\netstandard2.0\ | bin\Release\netstandard2.0\clash |

This is particularly wasteful for projects where the extra property has no effect (e.g., PublishReadyToRun on a netstandard2.0 class library that doesn't use ReadyToRun compilation).

Fix: Options include:

  1. Remove the extra global property - Investigate which parent target/task is injecting the property and prevent it from being passed to projects that don't need it
  2. Use RemoveGlobalProperties metadata - On ProjectReference items, use RemoveGlobalProperties="PublishReadyToRun" to strip the property before building the referenced project
  3. Condition the property - Only set the property on projects that actually use it (e.g., only for executable projects, not class libraries)

Explicit `` Build/Publish with extra global properties (self or cross-project)

Problem: A target uses the `` task to build or publish a project with an extra global property, most commonly a "publish-on-build" target. The offending call can be in the target project itself or in another project that consumes it (e.g. a test or layout project publishing a tool):


  

Either way this forks a distinct instance of the target project (path + {_IsPublishing=true}) that shares the same OutputPath/IntermediateOutputPath as the instance the solution/graph already builds. Both write the same files — for NativeAOT this includes the *.sourcelink intermediate, which produces SourceLinkWriter / "file in use" failures under parallel builds.

How to detect: Follow the Primary workflow above — the evaluations and evaluation_global_properties tools surface two evaluations of the target project that share the same OutputPath/IntermediateOutputPath but differ only by a path-neutral publish flag such as _IsPublishing, and the double_writes tool flags the resulting shared-file writes directly. To tell case (a) from (b), see which project the extra {_IsPublishing=true} evaluation runs under in the build tree (from the overview/projects tools): the target project itself for (a), or a consumer project that invoked the `` task for (b).

Fix: Depends on where the call lives:

  • Same project (a): you can't strip the property with RemoveGlobalProperties (the project injects it on itself). Set the flag as a static (non-global) property and run the target in the same instance via DependsOnTargets/CallTarget, with a guard against a target cycle when publish is the entry point:

  true
  true

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.