MiloszKrajewski / LibZ

LibZ, the alternative to ILMerge
Other
220 stars 33 forks source link

LibZ, the alternative to ILMerge

LibZ is an alternative to ILMerge. It allows you to distribute your applications or libraries as a single file with assemblies embedded into it or combined together into a container file.

Migration from codeplex

I believe sources and documentation have been fully migrated but you can still access old website here

License

Lib is licensed under Ms-PL. Long story short - you can use it, you can modify it as long as you don't claim you wrote it.

Change log

Changes can found here

Why not ILMerge?

ILMerge in many cases is the first thing you tried and it does what it does just fine, sometimes you just don't want it to do what it does, you just don't know that yet. Problems start to appear when your application uses reflection, or even worse, when 3rd part libraries use reflection. The alternative is "embedding" instead of "merging". Jeffrey Richter described this technique on his blog (and in his book) a few years ago. I think the best recommendation is the comment from Mike Barnett, author of ILMerge: "As the author of ILMerge, I think this is fantastic! If I had known about this, I never would have written ILMerge. Many people have run into problems using ILMerge for WPF applications because WPF encodes assembly identities in binary resources that ILMerge is unable to modify. But this should work great for them."

Download

Probably the best way to download it is to use the NuGet package LibZ.Tool. For advanced use (see: Scenarios) you may consider using other packages (LibZ.Library or LibZ.Sources) but only if you really know why (therefore, I'm not even linking to them from here).

Before you start

LibZ Container is not better than ILMerge, IL-Repack, Costura.Fody, etc. They do what they do well, they just lacked some features I needed (so I implemented them in LibZ). They also had some features which I didn't need (so I didn't implement them in LibZ). Carefully read what LibZ does and doesn't do before making a call. Some things I didn't like are just bugs (so they can be fixed sooner of later) some of them are just by design (and let me repeat, not bad design, just design for different purpose).

Motivation

There are multiple things which motivated me to write this library / tool.

Comparing LibZ with similar products

You can find matrix of features which were important to me here.

If you don't like reading manuals

I strongly recommend reading the Documentation, but if you just don't like reading manuals, and you need the simplest case just install the tool run it using command-line:

libz inject-dll --assembly MyApplication.exe --include *.dll --move

Done.

Please note that this approach works for trivial applications only. If your application (or 3rd party libraries) use reflection, application domains, native DLLs you might need more "personalised" approach. Please refer to Scenarios.