I developed a tool that slims down. NET programs

I developed a tool that slims down. NET programs

I have developed a tool that slims down. Net programs that can delete referenced but not used assemblies. I used it to slim down a. Net core program from 147 megabytes to 59.5 megabytes.

最后更新 12/26/2021 9:56 PM
杨中科
预计阅读 2 分钟
分类
.NET
标签
.NET C# slimming

我开发了一个对.Net 程序瘦身的工具,可以把被引用但是没有被使用的程序集删除。我用它把一个.Net core 程序从147兆瘦身到59.5兆。

NET has a function to tailor assemblies when publishing programs, but that function can only perform static checks. For example, our project uses assembly A. The classes in assembly A have two methods: M1 and M2. The M1 method calls the code of assembly B, and the M2 method calls the code of assembly C. If our program calls only the M1 method and not the M2 method, then using. NET clipping cannot clip out the C assembly that is called in the M2 method that is not called.

My tool can do runtime checks and delete assemblies that are not called at all at runtime (taking into account dynamic mechanisms such as reflection). NET does not support WinForm and WPF projects either.

The implementation principle of my tool is not complicated, but I searched around and couldn't find similar software, so I wrote one myself. If you know of such a tool, please let me know. If you confirm that this is my first, I will improve the software (test the compatibility of various projects and. NET versions and various operating systems) and release it and open source.

If this project is open source, I will publish it to my self-media. All friends can pay attention to my channels such as Beilai, Today's Headline, Douyin, Weibo, and Youtube. The channel names are all "Yang Zhongke".

Original author: Yang Zhongke

Original link: mp.weixin.qq.com/s/B7QdVQWtgBKNKOEFj2Lg4g

Keep Exploring

延伸阅读

更多文章
同分类 / 同标签 4/22/2026

Support for. NET by operating system versions (250707 update)

Use virtual machines and test machines to test the support of each version of the operating system for. NET. After installing the operating system, it is passed by measuring the corresponding running time of the installation and being able to run the Stardust Agent.

继续阅读
同分类 / 同标签 2/7/2026

Summary of experience in using AOT

From the very beginning of project creation, you should develop a good habit of conducting AOT release testing in a timely manner whenever new features are added or newer syntax is used.

继续阅读