有没有一个工具可以编译“选择性”仅包含某些类型的程序集?
假设我有一个包含类型 A
到 Z
的大型项目。
如果出于某种原因,我想将仅类型A
打包并分发给某些客户端,该怎么办?
显然我不能无条件地将A
编译成它自己的DLL;它可能取决于我的项目中的一些其他类型。但它不太可能取决于我项目中的每种类型。
我设想的是一些工具,可以检查 A
,识别其依赖项,并以某种方式编译一个最小的 DLL,其中仅包含我想要的类型 (A
) 所需的类型就这样了。
例如,如果 A
依赖于 B
和 C
提供的功能,并且 B
依赖于 D
,但 C
和 D
没有额外的依赖项(除了可能的 A
、B
或彼此),这个工具将从 A
到 D
并将仅这些类型编译到 DLL 中,供我按照我认为合适的方式进行处理。
通过 Visual Studio 可以使用此类功能吗?如果没有,是否有一些插件或外部工具能够执行此操作?顺便问一下,我问的问题是否合理,或者您认为这样的事情是一个坏主意?
显然我总是可以手动执行此操作;看起来这需要做很多工作(如果一开始这是一个坏主意,那么就忘记它吧)。
Say I have a large project containing the types A
through Z
.
What if, for whatever reason, I want to package and distribute just type A
to some client(s)?
Obviously I cannot just compile A
into its own DLL unconditionally; it may depend on some other types in my project. But it's unlikely it depends on every type in my project.
What I'm envisioning is some tool that could examine A
, identify its dependencies, and somehow compile a minimal DLL with only the types required for the type I want (A
) and no more.
So for example if A
depends on functionality provided by B
and C
, and B
depends on D
, but C
and D
have no additional dependencies (aside from possibly A
, B
, or each other), this tool would take A
through D
and compile just those types into a DLL for me to do with as I see fit.
Is such functionality available through Visual Studio? If not, is there some add-in or external tool capable of doing this? Incidentally, is what I'm asking about even reasonable, or do you feel that something like this would be a bad idea?
Obviously I could always do this manually; it just seems like that would be a lot of work (and if it's a bad idea to begin with, well, then just forget it).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来像是一个 make 文件的理想问题。我不知道 .NET 位将如何发挥作用,但对于经典的 C 模型,您可以执行以下操作:
运行
make clean A
,您应该获得 A 所需的一切,仅此而已。This sounds like an ideal problem for a make file. I don't know how the .NET bit will play into it but for the classic C model you could do something like this:
Run
make clean A
and you should get everything you need for A and nothing more.