views:

898

answers:

3

Let's assume I have a C# Winforms project, MainGUI.

It references another project in the same solution, ControlsLib.

ControlsLib references a third party control suite, such as Infragistics or Telerik controls, and exposes a set of user controls, that are used in MainGUI.

Copy Local is set to true on all the references in ControlsLib, and all the third party DLLs appear in ControlsLib\bin\release.

However I cannot get the third party DLLs to copy automatically to MainGUI\bin\release, which is the folder from which the software's installer is generated (in this case using NSIS)

Therefore the third party control DLLs don't get included in the installation, which leads to a FileNotFoundException at runtime when controls from ControlsLib that depend on the third party DLLs are used.

Is there a "proper" way to do this that I'm not aware of? Previously I've just handled this in a nant build script by copying files around, but I'm starting a new project and I just wanted to check.

Thanks

A: 

You would need to add a link to the necessary files from the UI project (MainGUI) and set them to copy to the output folder from there. The inbuilt packaging tools do (IIRC) cascade these correctly, but for external tools I expect you'll need to do it manually.

On my build server, I use a script that investigates references, and adds in all the descendent references just before it is built (by editing the csproj files as xml)... the code is not great, but it does the job.

Marc Gravell
A: 

I have had a similar problem using Gentle.NET (O/R Mapper). One of the DLLs refuses to copy. I've investigated for hours and have been unable to find a reason. All the other files are being copied, but THAT one is excluded for some odd reason. Gentle used three DLLs, Gentle.Common.DLL, Gentle.Framework.DLL and Gentle.SQLProvider.DLL. The last one never gets copied.

In the end I simply made a script…

Martín Marconcini
+1  A: 

I have just solved this by adding the following post build event command line to the .csproj file for MainGUI (project properties -> build events)

copy $(SolutionDir)ControlsLib\bin\$(ConfigurationName)\Infragistics2*.dll $(TargetDir)

I hadn't realised doing that was so easy actually...

tomfanning