Copying a DLL's dependencies in Visual Studio

2019-01-03 09:00发布

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?

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.

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.

8条回答
等我变得足够好
2楼-- · 2019-01-03 09:57

I don't like to have my dependency files located in the project root folder but in a subfolder. But the files has to be placed in the root folder in the build folder.

My build events look like this:

enter image description here

enter image description here

enter image description here

 Command: call xcopy /S /Y "$(SolutionDir)Dependencies\*.*" "$(TargetDir)"

In case "Dependencies" also contains subfolders, as mine does.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-03 09:58

I'm not really aware of any way to do this other than adding a reference to said .dll in the project itself. We've run across this in some of our own projects here, and the only solution we've found is to add the reference. I want to say that one of our developers did some research and found this to be the only solution, but don't quote me on that.

查看更多
登录 后发表回答