dotnet / dotnet/msbuild

Public reference from project reference is copied twice when included with a Link

Open
#11,324 3 comments 0 reactions 1 assignee Claimed by @ViktorHofer View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

A library included as an item with a LinkBase, is copied twice if it is also referenced with Private=False in a project reference.
It is copied both to the root of the output directory as to the Link path.

Ratioanle:
I have a library that uses Private=False references as these need to be referenced on runtime by the already installed libraries of another application.
I have a Console application that references this library. In here, I want to copy these external references to a folder, so they are not automatically linked when running and I can decide on runtime to either use these copies or the ones that are already installed .
I also have other projects, using this LibUsingExternalLib library, that don't need the copy to the folder. One of them is packaged with the external app

### Steps to Reproduce

ConsoleApplication:
```


Always





```

LibUsingExternalLib:
```


..\Libs\SomeExternalLib.dll
False


```

[PublicReferenceFromProjectReference.zip](https://github.com/user-attachments/files/18518583/PublicReferenceFromProjectReference.zip)

### Expected Behavior

Only have the reference in the libs\ folder

### Actual Behavior

The reference is both in the root of the output directory as in the libs\ folder

### Analysis

It is the expected behavior if I:
* also add a Private=False reference to SomeExternalLib in ConsoleApplication or
* add the include content to LibUsingExternalLib instead of ConsoleApplication

So it seems include items that are referenced are somehow also added to the output folder, but the Private=False is somehow lost?

### Versions & Configurations

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.