Reputation: 67
I have a Visual Studio 2019 solution that I inherited from someone else with multiple projects. I'm trying to build one of the projects in particular. I have a reference to an external assembly with "copy local" set to true.
When I build my project, my referenced assembly gets copied over tot he output folder but then it gets deleted.
I know it gets copied because I have tried using the post build event "dir $(TargetDir)" and it shows the dll.
Any idea why it would get deleted afterward?
Upvotes: 0
Views: 712
Reputation: 67
The problem was caused by by these lines in my csproj file:
<Target AfterTargets="AfterBuild;NonWinFodyTarget" Name="CleanReferenceCopyLocalPaths">
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>
The solution was using Fody to weave the assemblies. I had removed the weaving, but this line in the csproj file was a left over from the use of Fody.
Upvotes: 1
Reputation: 23780
The issue is that you have used some nuget packages like Costura.Fody
which could merge your specific external assembly into the main output file while it is set to Copy Local True.
So please check if your FodyWeavers.xml
file has any merge operation of your external assembly.
In my side, I have an external assembly called ClassLibrary22.dll
and set it to CopyLocal to true
.
And add these on FodyWeavers.xml
file:
So the assembly ClassLibrary22.dll
will be merged into the main project exe
or dll
output file and did not exist under output folder.
That is the cause.
Upvotes: 0