dotnet / dotnet/msbuild

[Broken Build]: Native DLL output deleted on IncrementalClean

Open
#10,931 8 comments 1 reaction 0 assignees View on GitHub
bug triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 19h
Merged PRs (30d)
135

Description

### Issue Description

I have a `WPF` exe project referencing a `Library` project which in turn references a `Native DLL` project. See attached sample project.

When rebuilding the solution, the output folder of the exe project contains all binaries:
```
MyLib.dll
NativeLib.dll
WpfApp2.dll
WpfApp2.exe
```
Then, perform any code change in the `WpfApp2` project and **Build** it (`F7` on my setup). The `NativeLib.dll` gets deleted. Using verbose logging, I can see that it incorrectly gets picked up in `_CleanOrphanFileWritesInOutput` processed by the `IncrementalClean` target.

### Steps to Reproduce

See attached sample project.

[SimpleApp.zip](https://github.com/user-attachments/files/17620929/SimpleApp.zip)

### Expected Behavior

Native DLL output should not be deleted when building solution.

### Actual Behavior

Native DLL output is deleted when building solution.

In real-world solutions, this causes runtime errors. We have spent many days trying to debug issues that weren't real issues; the build is in fact broken.

### Ask us questions

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the behavior with the attached SimpleApp.zip: rebuild the solution, change WpfApp2, and build it again while enabling verbose logging. Inspect the IncrementalClean target and _CleanOrphanFileWritesInOutput processing; done means NativeLib.dll remains in the WpfApp2 output after the incremental build.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.