将DLL生成到单独的文件夹 [英] Build DLL to a separate folder

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

问题描述

第一

有几个与此类似的问题,但无一个有答案 解决了我的问题,也无法在其中发布.最接近的是此问题.

There are several questions similar to this, but none have answers that solved my problem nor can I post in them. The closest one is in this question.

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

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:

要这样住:

推荐答案

我在此处并在此处转录以了解链接是否死亡.

I found the answer here and transcribed here for the case of the link die.

在您的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生成到单独的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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