将输出引用程序集构建到子文件夹 [英] Build output reference assemblies to subfolder
问题描述
背景
我的程序集(一个 DLL)正在被第三方应用程序加载,我无法控制它是如何加载的.第三方应用程序将加载给定目录中的所有程序集.
My assembly (a DLL) is being loaded by a third party application, I have no control over how it is loaded. The third party app will load all assemblies in a given directory.
问题
如果我的程序集和另一个程序集使用相同的库,但版本不同,它们将位于同一目录中并且会发生冲突.我已经研究了 <probing>
配置文件指令和程序集解析器,所以我知道如何创建子目录并让我的程序集搜索参考.
If my assembly and another assembly use the same library, but different versions, they will both be in the same directory and will conflict. I have already researched the <probing>
config file directive, and Assembly Resolvers, so I know how to create a subdirectory and have my assembly search it for references.
需要
我需要某种方式来配置 Visual Studio,以便将我的主 DLL 构建到根文件夹中,并将所有引用构建到一个子文件夹中.最好在构建期间(因为我将构建配置为直接转到正确的文件夹.
I need some way of configuring visual studio to build my main DLL into the root folder, and all references into a subfolder. Preferably during build (since I configured my build to go directly to the correct folder.
推荐答案
您可以将参考文献放在单独的文件夹中.方法如下:
You can put your references in separate folders. Here is how:
- 将文件夹添加到您的项目根目录.
- 将文件夹重命名为适当的名称.
- 右键单击文件夹,然后从添加 -> 现有项目
现在选择 &将任何参考程序集添加到此文件夹.您可以添加文件作为链接
右键单击引用并转到添加引用 -> 浏览
导航到您新创建的文件夹并选择程序集.
Navigate to your newly created folder and select assemblies.
将每个引用的 Copy to Local 设置为 True.
Set Copy to Local to True for each Reference.
构建您的项目.
这篇关于将输出引用程序集构建到子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!