有没有一个工具可以编译“选择性”仅包含某些类型的程序集?

发布于 2024-09-30 16:51:27 字数 742 浏览 0 评论 0原文

假设我有一个包含类型 AZ 的大型项目。

如果出于某种原因,我想将类型A打包并分发给某些客户端,该怎么办?

显然我不能无条件地将A编译成它自己的DLL;它可能取决于我的项目中的一些其他类型。但它不太可能取决于我项目中的每种类型。

我设想的是一些工具,可以检查 A,识别其依赖项,并以某种方式编译一个最小的 DLL,其中仅包含我想要的类型 (A) 所需的类型就这样了。

例如,如果 A 依赖于 BC 提供的功能,并且 B 依赖于 D,但 CD 没有额外的依赖项(除了可能的 AB 或彼此),这个工具将从 AD 并将仅这些类型编译到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞美少年 2024-10-07 16:51:27

这听起来像是一个 make 文件的理想问题。我不知道 .NET 位将如何发挥作用,但对于经典的 C 模型,您可以执行以下操作:

clean :
    del *.obj

libA.lib : A.obj
    makelib *.obj

libB.lib : B.obj
    makelib *.obj

...

A.obj : B.obj C.obj
    compile A.cs

B.obj : C.obj D.obj
    compile B.cs

C.obj : 
    compile C.cs

D.obj : 
    compile D.cs

...

运行 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:

clean :
    del *.obj

libA.lib : A.obj
    makelib *.obj

libB.lib : B.obj
    makelib *.obj

...

A.obj : B.obj C.obj
    compile A.cs

B.obj : C.obj D.obj
    compile B.cs

C.obj : 
    compile C.cs

D.obj : 
    compile D.cs

...

Run make clean A and you should get everything you need for A and nothing more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文