I have ProjectA(WPFApplication) that references ProjectB(ClassLibrary). Inside ProjectB i have wpf window that uses contro
You should add the reference to the thrid party dll to the project where you want it to appear in the output directory. If the Copy Local is then set to true it will appear in you bin directory whether or not you use it in code or xaml.
Add something like this to ProjectB.csproj:
<ItemGroup>
<Content Include="...\path\ThirdParty.dll">
<Link>ThirdParty.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
This convinces VS to copy ThirdParty.dll to the output folder of ProjectA, too
(no need to add anything to ProjectA about ThirdParty.dll).
I still find it inadequate because if ThirdParty.dll is in a NuGet package, its path usually contains version number, which will change when you update the package.
I haven't tried it yet but I don't expect from NuGet to update the path here as it does in <Reference>
.
The reason for this is that visual studio only copies resources to the output folder if Copy Local is set. Just set the reference to Copy Local and you should be fine.
Check out this link on how this works.
When you reference ProjectA, the references from ProjectB is not automatically referenced. For this to work, you need to add a reference to ThirdParty.dll from ProjectA as well if you only use it in XAML. The compiler does not copy references that are only used in XAML. But if you use them in code, they are copied.
This is the same issue as discussed here