如何在 .NET Core 中排列应用程序 DLL 文件

5
我在dotnet core 3.1中构建了一个应用程序,构建后在bin文件夹中看到了许多dll和xml文件。这是屏幕截图:dll hell 我希望它看起来像这样:enter image description here 请问有人能帮帮我吗?:-((((

1
在此链接下有2个答案:https://dev59.com/XEvSa4cB1Zd3GeqPbhvy。 - BlueCompany
@Adriani6 我认为他想要对输出进行结构化,而不仅仅是更改输出文件夹路径。还是我有所遗漏? - BlueCompany
@BlueCompany 不好意思,我在截图中漏掉了根目录下的exe文件,不过你发现得真好 :) - Adrian
BlueCompany - 我尝试过这个方法,但我使用的是 .NET Core 而不是 .NET Framework,因此我的应用程序可以在没有 app.config 的情况下工作,而 PrettyBin 则无法正常工作。 - doronazu
找到了另一个来源:https://weblog.west-wind.com/posts/2019/Apr/30/NET-Core-30-SDK-Projects-Controlling-Output-Folders-and-Content 但是现在已经太晚了,我来不及测试。不过这是个好问题。 - BlueCompany
(a) 我强烈建议不要去碰它,并且增加可能出现的问题层。这是我的意见。 (b) 考虑使用 dotnet publish /p:PublishSingleFile=true 来发布你的代码。 - granadaCoder
1个回答

2
在 .net framework 中,你可以在 app.exe.config 中使用 AssemblyBinding probing,并且可以使用 Visual Studio 中的 Post Build Events Command Line 将你的 dll 和 xml 移动到自定义文件夹中。
在 .net core 3.1 中,additionalProbingPaths 似乎不能很好地工作,但你仍然可以使用 Post Build Events Command Line 将你的 xml 移动到自定义文件夹中。
注意: 1. AssemblyBinding probingadditionalProbingPaths 会影响你程序集加载 dll 的位置。 2. 如果你不知道如何使用 Post Build Events Command Line,请查看 指南
关于探测路径,请参见以下问题: Additional probing paths for .NET Core 3 migration donet/sdk issue
最后,我发现 nulastudio.NetCoreBeauty 库似乎具有你想要的功能。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接