简体   繁体   English

防止 Visual Studio 复制引用的 dll

[英]Prevent Visual Studio from duplicating referenced dll

I'm working on a plugin system for my app (C#, WPF).我正在为我的应用程序(C#、WPF)开发插件系统。 My project structure is like this:我的项目结构是这样的:

Solution 'App'
    Plugins (solution folder)
        Plugin1 project (dll)
        Plugin2 project (dll)
    MainApp project (WPF)
    PluginInterface project (dll)

I edited projects' properties to build them in a custom folder this way我编辑了项目的属性,以这种方式将它们构建在自定义文件夹中

Build
    Debug
        MainApp.exe
        PluginInterface.dll
        Plugins (folder)
            Plugin1.dll
            Plugin2.dll

As the plugins should implement Iplugin interface (in PluginInterface project), I added PluginInterface project to references for each plugin project.由于插件应该实现Iplugin接口(在 PluginInterface 项目中),我将 PluginInterface 项目添加到每个插件项目的引用中。 However, this causes Visual Studio to build a copy of PluginInterface.dll in Plugins folder while PluginInterface project's output path is just set to Build\Debug.但是,这会导致 Visual Studio 在 Plugins 文件夹中构建 PluginInterface.dll 的副本,而 PluginInterface 项目的 output 路径只是设置为 Build\Debug。

I also tried to reference to the PluginInterface.dll file in Build\Debug (not project) but the result is same (I didn't forget to delete all created files before build).我还尝试在 Build\Debug(不是项目)中引用 PluginInterface.dll 文件,但结果是相同的(我没有忘记在构建之前删除所有创建的文件)。

How should I prevent Visual Studio from duplicating PluginInterface.dll file?我应该如何防止 Visual Studio 复制 PluginInterface.dll 文件?

You could always remove the file afterwards with an msbuild task;之后您始终可以使用 msbuild 任务删除该文件;

https://docs.microsoft.com/en-us/visualstudio/msbuild/delete-task?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/msbuild/delete-task?view=vs-2019

Or with a post-build script;或者使用构建后脚本;

del $(ProjectDir)\plugins\pluginInterface.dll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Visual Studio中调试引用的DLL - Debugging referenced DLL in Visual Studio 如何从Visual Studio 2012调试引用的dll - How can I debug a referenced dll from Visual Studio 2012 找不到引用的Nuget DLL,可以在Visual Studio中正常工作 - Referenced Nuget DLL Not Found Working Visual Studio 如何防止 Visual Studio 在错误列表中复制错误? - How do I prevent Visual Studio from duplicating errors in the error list? 如何防止引用的程序集的嵌入式依赖项被复制到Visual Studio中的输出文件夹? - How to prevent a referenced assembly's embedded dependency from being copied to output folder in Visual Studio? 调试Visual Studio宏中引用的自定义dll - Debug custom dll that is being referenced in visual studio macro Visual Studio 找不到我引用的 DLL 的命名空间 - Visual studio cannot find my referenced DLL's namespace Visual Studio 2022 将引用的 dll 放入 bin 文件夹的子目录中 - Visual Studio 2022 place referenced dll into subdirectory of bin folder Visual Studio:调试引用的DLL,我在另一个SLN中有源代码 - Visual Studio: Debugging a referenced DLL, I have source in another SLN 在 Visual Studio 中复制行的快捷方式? - Shortcut for duplicating lines in Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM