One nice thing about managed applications is the push for touch-free application deployment. Paint.NET is a perfect example of a relatively powerful application that can simply be copied to any machine with the required .NET Framework version installed and then executed. With the recent release of Paint.NET v2.62 I wanted to take advantage of touch-free deployment but in a smaller package that I could easily fit on my USB flash drive or download in minimal time with minimal space required.
I first installed Paint.NET, which is about 11 MB in side. I then created a new directory, copying only the necessary files for an English UI since the included license allows me to do so. The resultant file set I choose follows.
That cuts down the size to about 1.71 MB. Nice, but it could be smaller. One idea was to create a custom CLR host that’s simply a stub executable with an embedded cabinet. While this would be an interesting side project, I’ve already got other projects in the works which I hope to publish soon. There is, however, already a useful tool for compressing these files into a self-extracting executable, and it has shipped with Windows for quite some time: iexpress.exe.
Its purpose is to extract files and run a setup application, but nothing precludes it from running another application such as Paint.NET.exe. Run iexpress.exe which starts a simple wizard. The most important steps to remember are to have it execute Paint.NET.exe, and to store the files using long names. The latter step will prevent the package from running on Windows 95, but the .NET Framework 2.0 which at least Paint.NET v2.62 requires isn’t supported on Windows 95 anyway.
The result was a 595 KB executable. It quickly extracts the files to a sub-directory under %TMP% and runs Paint.NET.exe. When you close Paint.NET.exe the temporary files are cleaned-up. Sure, better compression rates are likely possible using different tools but this is a good start to compress Paint.NET even more without adding extra steps to start the application.