[英]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.