Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2008.NET: Getting a referenced project's dependencies to copy to main project's bin folder

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

like image 517
tomfanning Avatar asked Mar 11 '09 12:03

tomfanning


People also ask

How to Add Reference in project in c#?

To add a reference, right click on the References or Dependencies node in Solution Explorer and choose Add Reference. You can also right-click on the project node and select Add > Reference.

How to Add an assembly Reference in c#?

In the Project Designer, click the References tab. Click the Add button to open the Add Reference dialog box. In the Add Reference dialog box, select the tab indicating the type of component you want to reference. Select the components you want to reference, and then click OK.


1 Answers

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...

like image 177
tomfanning Avatar answered Nov 15 '22 06:11

tomfanning