将 .NET 程序集移离应用程序基目录?

发布于 2024-08-26 04:19:28 字数 739 浏览 3 评论 0原文

我有一个带有大量第三方引用的 WinForms 应用程序。这使得输出文件夹非常混乱。我想将编译/引用的 dll 放入输出文件夹中的公共子目录中,bin / lib - 无论什么 - 并且只需将可执行文件(+所需的配置等)驻留在输出文件夹中。

经过一番搜索后,我遇到了程序集探测(http://msdn.microsoft.com /en-us/library/4191fzwb.aspx) - 并验证如果我设置此设置并手动移动程序集,如果它们存储在指定的子目录中,我的应用程序仍然可以工作,如下所示:

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

但是,这并不'无法解决构建部分 - 有没有办法指定引用的程序集和编译的库程序集的去向?

我能立即想到的唯一解决方案是构建后操作或放弃这个想法并使用 ILMerge 或其他东西。

必须有一种更好的方法来定义结构:-)

I have a WinForms application with a bunch of third party references. This makes the output folder quite messy. I'd like to place the compiled / referenced dlls into a common subdirectory in the output folder, bin / lib - whatever - and just have the executables (+ needed configs etc) reside in the output folder.

After some searching I ran into assembly probing (http://msdn.microsoft.com/en-us/library/4191fzwb.aspx) - and verified that if I set this up and manually move the assemblies my application will still work if they are stored in the designated subdirectory like so:

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

However, this doesn't solve the build part - is there any way to specify where referenced assemblies and compiled library assemblies go?

Only solutions I can think of off the top of my head is either post-build actions or dropping the idea and using ILMerge or something.

There has got to be a better way of defining the structure :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拍不死你 2024-09-02 04:19:28

如果您在 Visual Studio 中进行构建,那么您绝对可以设置构建后操作 - 它们工作得非常好。我真的不认为有任何其他好的、有记录的方法可以做到这一点。不幸的是,我相信,当您引用另一个程序集时,没有选项可以定义在构建过程中将引用的 DLL 复制到何处。

当然,如果您从源代码构建这些程序集,您可以将其输出目录设置为 (app)\bin(app)\lib一开始,构建过程就会从一开始就把它们吐到正确的目录中。

如果您使用的是更复杂的构建服务器,您可能还可以将一些 DLL 文件移动到该工具中的单独目录中。

If you're building within Visual Studio, you can definitely set up post build actions - they work quite nicely. I don't really think there's any other good, documented way to do this. Unfortunately, when you reference another assembly, there's no option to define where to copy that referenced DLL to in the build process, I believe.

Of course, if you're building those assemblies from source code, you could just set up their output directory to be (app)\bin or (app)\lib from the beginning, and the build process would spit them into the right directory right from the get go.

If you're using a more sophisticated build server, you probably have means of moving a handful of DLL files to a separate directory in that tool, too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文