在Visual Studio中复制DLL的依赖项 [英] Copying a DLL's dependencies in Visual Studio

查看:201
本文介绍了在Visual Studio中复制DLL的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Visual Studio中设置项目以复制项目的引用依赖的第三方DLL?

How can I set up a project in Visual Studio to copy the third-party DLLs that one of the project's references depends on?

我有一个主要的应用程序项目和一个类库DLL。主应用程序引用了类库DLL,DLL本身引用了一些第三方DLL。当我编译主应用程序时,它将自动将类库DLL复制到其输出目录,但不会复制第三方DLL。

I have a main application project and a class library DLL. The main application references the class library DLL, and the DLL itself references some third-party DLLs. When I compile the main application, it automatically copies the class library DLL to its output directory, but it does not copy the third-party DLLs.

我不想从主应用程序项目添加对第三方DLL的引用,因为主应用程序不使用它们,它们只能被类库使用。

I do not want to add references to the third-party DLLs from the main application project because the main application does not use them, they're only used by the class library.

推荐答案

您可以使用项目属性窗口来实现此目的。 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)"

其中 $(SolutionDir) $(TargetDir )都是预定义的变量。标准语法如下:

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

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

如果您点击编辑帖子建立...按钮,它将弹出一个框,其中列出了这些预定义变量您可以插入(如 $(SolutionDir) $(TargetDir)

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.

这篇关于在Visual Studio中复制DLL的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆