msbuild
msbuild copied to clipboard
[Bug]: No idiomatic method to prevent content files from referenced projects overwriting files in main project
Issue Description
I have read about ErrorOnDuplicatePublishOutputFiles
but that only works on Publish (i.e. not build), and isn't what I want. I want to be able to specify that a file should not be brought in from the referenced project at all. I have tried adding PrivateAssets=none
to the ProjectReference
in the csproj file, to no avail.
Steps to Reproduce
- Clone https://github.com/nbarnwell/ConflictingContentFilesTest
- Build in Visual Studio
Expected Behavior
The appsettings file in the output folder should be the one from the main project.
Actual Behavior
The appsettings file in the output folder is the one from the ExternalLibrary project.
Analysis
I believe this is a change in behaviour of project references from .NET Framework? I understand bringing in content files from packages, but not projects. With a package, you have deliberately packaged it to contain certain files, but that step is implicit in project references, so you have no control over what is brought in. There is some setting somewhere about not bringing in content files from transitive project references, but that's not what I'm looking for, either.
Versions & Configurations
MSBuild version 17.10.4+10fbfbf2e for .NET Framework 17.10.4.21802
Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.10.4