[英]Build project's components to own .dlls
I have project, which contains lot of classes. 我有一个项目,其中包含很多类。 I use this project as plugin base for one of my application.
我将此项目用作我的一个应用程序的插件基础。 This app can load all these plugins from one .dll builded from this project.
这个应用程式可以从这个专案建立的.dll载入所有这些外挂程式。
Problem is, I need to use these plugins in third-side app. 问题是,我需要在第三方应用程序中使用这些插件。 This app can load only one plugin per .dll.
该应用程序每个.dll只能加载一个插件。 I have very few options here.
我这里的选择很少。 As far as I know, I could create new project for each file and build them.
据我所知,我可以为每个文件创建一个新项目并进行构建。 But it is sloppy way how to solve it.
但这是草率的解决方法。
So, is there any way, how to build one project for each of its classes or for groups of classes? 那么,有什么方法可以为每个类或每个类组构建一个项目?
It sounds to me as task for some script. 在我看来,这是一些脚本的任务。 Is possible to achieve this for example with psake or powershell?
可以使用psake或powershell实现此目的吗?
Thanks in regards 谢谢问候
Well, I believe that they are already doing that in their own bin directories. 好吧,我相信他们已经在自己的bin目录中这样做了。 That`s if you mean assemblies as components.
那就是如果您将程序集作为组件。 If you are talking about classes, then you should place them in separate assemblies and use the same approach.
如果要讨论类,则应将它们放在单独的程序集中,并使用相同的方法。
You can right click on assembly and go to properties, build where you can see the 'output path' field as well as 'XML documentation' checkbox which is required for third-side apps to see your XML comments while using .dll-s. 您可以右键单击程序集并转到属性,在此处可以看到“输出路径”字段以及“ XML文档”复选框的位置,这是第三方应用程序在使用.dll-s时查看XML注释所必需的。
One way I can think of is to create a 'template' project file based on the Plugin project you already have. 我能想到的一种方法是根据您已有的Plugin项目创建一个“模板”项目文件。 You can make a copy of the plugin.csproj and then delete all included plugin classes.
您可以复制plugin.csproj ,然后删除所有包含的插件类。 Using psake and Powershell you can dynamically add the plugin class you need an assembly for and then call MSBuild to build the csproj.
使用psake和Powershell,可以动态添加所需的程序集所需的插件类,然后调用MSBuild来构建csproj。
<ItemGroup>
<Compile Include="MyFirstPlugin.cs" />
</ItemGroup>
Adding xml-nodes like this to an csproj-file is easy to do in Powershell. 在Powershell中很容易将这样的xml节点添加到csproj文件中。
The pseudo code for the ps script could be something like this; ps脚本的伪代码可能是这样的。
define list of plugin cs-files
for each plugin cs file
copy template.csproj to plugin.csproj
add xml node to include plugin.cs file
call msbuild on plugin.csproj
delete plugin.csproj file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.