Copying a DLL’s dependencies in Visual Studio

You can achieve this with the project properties window. Visual Studio allows you to define events to occur, before, or after building. To get to the project properties window simply right-click on your project in the solution explorer window and click on ‘properties’. From the left hand side go to the ‘build events’ tab.

In the post-build box type in a few copy commands. For example:

copy "$(SolutionDir)mydll.dll" "$(TargetDir)"

Where $(SolutionDir) and $(TargetDir) are both predefined variables. The standard syntax is as follows:

copy "source directory and file name" "destination directory"

If you click on the ‘edit post build…’ button it will bring up a box which has a listing of these predefined variables that you can insert (like $(SolutionDir) and $(TargetDir))

As a side note, this is a useful process for copying other files, such as custom configuration files, images, or any other dependencies your project may have.

Leave a Comment