且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Visual Studio:将依赖的DLL复制到目标文件夹

更新时间:2022-12-12 16:39:17

我要做的是将所有DLL放在一个文件夹中(特定于Debug/Release等),然后将它们复制回到适当的输出文件夹中.您的EXE.

What I'd do is to put all DLLs in a single folder (specific to Debug/Release etc), and copy them back to the appropriate output folder of your EXE.

这只能通过两个操作来完成:

This can be done in only two actions:

  • 将所有DLL的输出目录设置为$(ConfigurationName)_$(PlatformShortName)

  • 选择所有DLL项目
  • 右键单击->属性
  • 选择所有配置和所有平台
  • 设置输出目录

向EXE项目添加生成后操作,这对于将$(ConfigurationName)_$(PlatformShortName)\*.dll复制到$(TargetDir)

Add a post-build action to the EXE project, common to all configurations that copies $(ConfigurationName)_$(PlatformShortName)\*.dll to $(TargetDir)

编辑

第二步出现问题,因为EXE的$(ConfigurationName)与DLL项目不同.不确定,但是也许您可以推断出相应的配置,以便对所有18个配置都保留一个构建后事件.可能是一个新的SO问题:)

There is a problem in the second step since the $(ConfigurationName) of your EXE is not the same as your DLL projects. Not sure but maybe you can have a way to deduce the corresponding configuration, in order to still have a single post-build event for all your 18 configs. It can be a new SO question:)