dotnet / dotnet/project-system

Build Acceleration can copy unused assembly reference to output directory

Open
#9,575 4 comments 1 reaction 0 assignees View on GitHub
Feature-Build-Acceleration Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

_(Originally reported in #9574. Restated here in a more minimal form after some investigation.)_

Consider two projects:

## Project A

```xml


net8.0



```

## Project B

```xml


net8.0



```

```c#
class C
{
void M()
{
// Use code from MyAssembly.dll, referenced by ProjectA
new TypeFromMyAssembly();
}
}
```

---

Rebuilding (i.e. without VS's FUTDC) the above ends up with something like (slightly abridged):

```
ProjectA
bin
Debug
net8.0
MyAssembly.dll
ProjectA.dll
ProjectB
bin
Debug
net8.0
MyAssembly.dll
ProjectA.dll
ProjectB.dll
```

However, if you comment the usage of `TypeFromMyAssembly` in `C.M` and rebuild, then `MyAssembly.dll` is removed from the output directory of Project B.

The build is able to determine whether the referenced assembly is actually used or not, and only copies when it is.

Build Acceleration is not aware when a referenced assembly is unused, and will always try to copy the file to the output directory. This can cause extra files to be present in the output directory when Build Acceleration is enabled.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.