When I build a specific project there is an undesired file being copied into the output from a nuget package during the _CopyFilesMarkedCopyLocal
task. I can't determine from the logs or a search of project references why the file is marked CopyLocal. Is there anything logged that could help? Or is there a property or item group that I can start printing out debug messages to track it down?
The file is part of a Nuget package, but it isn't directly referenced in the project where the copy happens.
The project where the copy happens is part of a large complex .NET Framework application. The project has 5 PackageReference
, and 1 ProjectReferences
. The ProjectReference project has an additional 17 PackageReferences
and 7 ProjectReferences
and the tree keeps going.
NuGet will generate obj\...nuget.g.props
/.targets
file that contains the reference.
This can be controlled via Dependency asset attributes - e.g. setting ExcludeAssets="contentfiles"
on the PackageReference
.
Using a binary log (adding -bl
to msbuild/dotnet build
invocations) and opening it in the structured log viewer gives you good search options in the logical build tree and the files / log output which can help find these files.