将DLL生成到单独的文件夹

将DLL生成到单独的文件夹

本文介绍了将DLL生成到单独的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一

我在此处.我在这里发布,以便我找到它 以后.

I found the answer here. And I am posting here so I can found it later.

问题:如何构建项目并将我的所有Referenced Library放在lib子文件夹中?

The Question: How to build my project and have all my Referenced Library inside a lib sub-folder?

一个想要这个输出目录:

A want this output directory:

要这样住:

推荐答案

在您的App.config文件中,插入以下内容:

In your App.config file, insert this:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="lib" />
    </assemblyBinding>
  </runtime>
</configuration>

然后转到Project -> Properties ---右键单击Project,然后在ContextMenu中选择Properties.

Then go to Project -> Properties --- right click in your Project, then in the ContextMenu select Properties.

现在转到Build Events并在Post-build event command line文本框中添加以下代码(如下面的图像所示).

Now go to Build Events and add the following code inside the Post-build event command line text box (as you can see in the bellow image).

; Move all assemblies and related files to lib folder
ROBOCOPY "$(TargetDir) " "$(TargetDir)lib\ " /XF *.exe *.config *.manifest /XD lib logs data /E /IS /MOVE
if %errorlevel% leq 4 exit 0 else exit %errorlevel%

之后

建立您的项目,并向您的强迫症说再见!

Build your project and say good bye to your OCD!

这篇关于将DLL生成到单独的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!