将DLL构建到单独的文件夹

问题描述 投票:1回答:1

第一

有几个类似的问题,但没有一个问题可以解决我的问题,也不能在其中发布。最接近的是在this question

我找到了答案here。我在这里发帖,所以我可以在以后找到它。

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

想要这个输出目录:

Lots of DLLs in the main folder

要保持这样:

enter image description here

c# wpf visual-studio winforms nuget-package
1个回答
7
投票

我找到答案here并在这里转录链接死亡的情况。

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

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

然后去Project -> Properties ---右键单击你的Project,然后在ContextMenu选择Properties

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

; 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%

Post-build event command line

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

© www.soinside.com 2019 - 2024. All rights reserved.