I was recently working on a WPF MVVM application that used MEF to load plugins. I had broken up the main WPF application into smaller more manageable compartmentalized projects to help ensure more cross platform code. But when I tried to run the program it would start up fine but as soon as it tried to utilize logic from my plugins I was getting "assembly or one of it’s dependencies not found" exceptions.

Main Application
    -> LibraryA (References to Xceed.WPF.Toolkit)

Turns out when visual studio compiled my solution it was not copying Xceed.Wpf.Tookit into the main application bin/Debug folder. To solve this took a lot of searching on the interwebz before coming across this handy solution. Recursively Copying Indirect Project Dependencies in MSBuild.

Just download the CopyIndirectDependencies.targets CopyIndirectDependencies.targets (9.19 kb) and put it in your main application folder. Then edit your projects .csproj file to include this line "<Import Project="CopyIndirectDependencies.targets" />"

 

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  ...

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Import Project="CopyIndirectDependencies.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

Now when you build your main application project it should scan for indirect dependancies and copy them to the projects bin/Debug folder.


Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume