Showing posts with label ILMerge. Show all posts
Showing posts with label ILMerge. Show all posts

Wednesday, February 13, 2013

Glima!... Gilma v3 is a .Net 4.0 update...

CodeProject - Gilma - GUI for the ILMerge Application Revised for .NET 4.0

image

Introduction

I saw the beautiful interface made by Tomer Shalev on the SourceForce Web site and thought I could rewrite it in a self-contained way. The original Tomer Shalev's Gilma is a front-end application to ILMerge: Microsoft's command-line utility that can be used to merge multiple .NET assemblies into a single assembly. ILMerge is freely available from Microsoft's Web site.
ILMerge's license does allow commercial usage.

In my implementation, the snapshot of which you can see in the image above, I have referenced the ILMerge executable directly in Visual Studio 2010.

Using the Code

The MSI file contained in the demo installs the application. .NET 4.0 Client profile and the 3.1 Installers are pre-requisites. In the source zip, the entire Visual Studio 201 project is contained.
The only thing to point out is the presence of the possibility to use a strong key in the preferred *.snk format to digitally sign the assembly.

...

I last blogged about Gilma five years ago (Gilma - GUI for ILMerge Branched for .Net 2.0). I guess it's okay to blog about it again, now... :)

 

Related Past Post XRef:
Want to ILMerge but you're building a WPF app? Resource them baby!
ILMerge get's a rev...
Have a bunch of referenced DLL’s cluttering up your deployment? Just say no and ILMerge them…
Automate ILMerge'ing - Using Project Attributes to mark an Assembly for merging and then MSBuild to ILMerge them...
Gilma - GUI for ILMerge Branched for .Net 2.0
VS2005 Power Toys Pack Installer
MSBuild and ILMerge
"Gilma - GUI for ILMerge Application"
ILMerge Updated
The Code Project - Merging .NET assemblies using ILMerge - .NET

Tuesday, January 15, 2013

Want to ILMerge but you're building a WPF app? Resource them baby!

The Telerik Blogs - How To: Merge assemblies into WPF application

As you may know you cannot use ILMerge to merge assemblies with XAML (WPF application) however there is a little known trick you can use to achieve your goal in a bit different way.

  • Add needed assemblies as embedded resources in your application
  • Load needed assemblies from embedded resources in runtime

How to do this?
First you need to ensure that all referenced assemblies (except the framework itself) are added properly to the application resources on every application build. To do this you can use this simple MSBuild task (AfterResolveReferences) at the end of your project:

..."

Funny how things happen...

Last night as I was about to leave work I downloaded ILMerge. I've been wanting to use it for forever (over 8 years... that's like forever!) and finally had a real business need to do so. So I downloaded it and planned on using it this morning.

Then I caught Vladimir's above article.

Now the app I need to merge is a command line app, but still I thought the resource approach cool, so I save the article for future reference.

I started down the ILMerge path and it wasn't going so well. Getting some weird errors building the EXE, etc. I head over to the ILMerge site and guess what I see?

A Great Alternative to using ILMerge

If you cannot use ILMerge because you are trying to merge WPF assemblies, then here is a great way for you to get the same effect, courtesy of Jeffrey Richter: embed the dlls you want to merge as resources and load them on demand! In many ways, this is a better technique than using ILMerge, so I strongly urge you to check it out, even if ILMerge is working for your scenario.

Cool! So the resource approach is not only not a hack but actually "good!" And while Jeff's article is good, I thought Vladimir's even better! Almost 100% cut-n-paste and done good!

Why almost? Remember I said I was using this approach with a command line app? Well you have to be careful there.

In short, don't do the resource assembly resource/event hookup in the same block of code where you use those assemblies. The JIT will get you.

So in the Main, do the assembly stuff as shown by Vladimir's  and move your code into another routine (so your code isn't JIT'd at the same time, same block.

Once you do that, you should be good. It's worked great for me today helping me greatly streamline the deployment of one of my app's. Talk about simple xcopy deployment! :)

 

Related Past Post XRef:
ILMerge get's a rev...
Have a bunch of referenced DLL’s cluttering up your deployment? Just say no and ILMerge them…
Automate ILMerge'ing - Using Project Attributes to mark an Assembly for merging and then MSBuild to ILMerge them...
Gilma - GUI for ILMerge Branched for .Net 2.0
VS2005 Power Toys Pack Installer
MSBuild and ILMerge
"Gilma - GUI for ILMerge Application"
ILMerge Updated
The Code Project - Merging .NET assemblies using ILMerge - .NET

Monday, August 06, 2012

ILMerge v2.12.x released

Microsoft Downloads - ILMerge

ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. See the accompanying documentation for details.

Version:2.12.0803
Date published: 8/6/2012

Language: English

ILMerge.msi, 726 KB

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly. ILMerge takes a set of input assemblies and merges them into one target assembly. The first assembly in the list of input assemblies is the primary assembly. When the primary assembly is an executable, then the target assembly is created as an executable with the same entry point as the primary assembly. Also, if the primary assembly has a strong name, and a .snk file is provided, then the target assembly is re-signed with the specified key so that it also has a strong name.

ILMerge is packaged as a console application. But all of its functionality is also available programmatically.

There are several options that control the behavior of ILMerge. See the documentation that comes with the tool for details.

..."

No word yet on what's new or updated (the latest noted on the Change History page is 2.11.1103), but this is the first release of ILMerge for the year, so worth a note. (I'm guessing something .Net 4.5 related, but that's a total WAG)

 

Related Past Post XRef:
ILMerge get's a rev...

Have a bunch of referenced DLL’s cluttering up your deployment? Just say no and ILMerge them…
Automate ILMerge'ing - Using Project Attributes to mark an Assembly for merging and then MSBuild to ILMerge them...
Gilma - GUI for ILMerge Branched for .Net 2.0
VS2005 Power Toys Pack Installer
MSBuild and ILMerge
"Gilma - GUI for ILMerge Application"
ILMerge Updated
The Code Project - Merging .NET assemblies using ILMerge - .NET

Monday, November 28, 2011

.NET assembly merging, three different approaches...

simonebu's space - Past, present and future of .NET assembly merging

Compiling code written for the .NET framework usually produces assemblies in the form of either standalone executables or libraries. These assemblies contain mainly Microsoft Intermediate Language (MSIL) code which is then jitted upon execution.

It's not uncommon for libraries which expose public APIs to rely internally on assemblies provided by third parties that should not end up in the final package. I'll take the mocking library NSubstitute as an example.

There are commonly a couple of reasons why they shouldn't. First, the client code does not need to reference them directly as they are only used internally. Back to the mocking framework example, it wouldn't make a lot of sense to build a dynamic proxy from scratch as there exist excellent implementations already, like Castle DynamicProxy, which NSubstitute uses.
The other reason is to avoid cluttering the release package of the library with dependencies that are of no interest to the end user, thus simplifying the distribution of the library which would then consist of a smaller number of files.

The aim is thus to embed somehow the dependent assemblies in a single assembly. There has been mainly a single approach to this so far, and it's called ILMerge.

ILMerge

Mike Barnett's ILMerge is a free tool which statically links several assemblies into a single output assembly. It runs as a console application and rewrites the IL of the main assembly by embedding the contents of the other assemblies into it. It takes care of a couple of additional things, like strong naming and target framework version, but accepts additional configuration options which allow further customization. One particularly useful is internalization of types, which allows to change the accessibility levels of the types contained in the dependent assemblies, thus effectively hiding them to everyone except the containing assembly.

...

Embedding assemblies as resources

Serializing other files into assemblies as resources has always been possible. Resources can then be deserialized at runtime and manipulated. They can be anything, although commonly used for storing media, icons and inanimate data in general. Nothing prevents you from storing assemblies in there, and load them at runtime...

...

Costura

Costura is a neat open source project developed by Simon Cropp which takes care of all the steps described above, and is thereby the suggested way to merge third party assemblies using the embedded resource approach. ..."

I've been following ILMerge for forever, and like the concept behind it (i.e. simplifying deployment). That said, this is the first  I've heard of Costura. Needless to say I'm watching it now... :)

Wednesday, September 28, 2011

ILMerge get's a rev...

Microsoft Downloads - ILMerge

"ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. See the accompanying documentation for details

Quick details

Version: 2.11.0923
Date Published: 9/25/2011

Language: English

File Name: ILMerge.msi, 744 KB

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly. ILMerge takes a set of input assemblies and merges them into one target assembly. The first assembly in the list of input assemblies is the primary assembly. When the primary assembly is an executable, then the target assembly is created as an executable with the same entry point as the primary assembly. Also, if the primary assembly has a strong name, and a .snk file is provided, then the target assembly is re-signed with the specified key so that it also has a strong name.

ILMerge is packaged as a console application. But all of its functionality is also available programmatically.

There are several options that control the behavior of ILMerge. See the documentation that comes with the tool for details.

..."

Not the most sexy of utilities, but one I'm seeing used more and more.  No news yet on what's in this update (keep an eye on  the ILMerge web site, as that's where I'm sure the details will be posted)

 

Related Past Post XRef:
Have a bunch of referenced DLL’s cluttering up your deployment? Just say no and ILMerge them…
Automate ILMerge'ing - Using Project Attributes to mark an Assembly for merging and then MSBuild to ILMerge them...
Gilma - GUI for ILMerge Branched for .Net 2.0
VS2005 Power Toys Pack Installer
MSBuild and ILMerge
"Gilma - GUI for ILMerge Application"
ILMerge Updated
The Code Project - Merging .NET assemblies using ILMerge - .NET

Tuesday, February 24, 2009

Have a bunch of referenced DLL’s cluttering up your deployment? Just say no and ILMerge them…

Daniel Cazzulino's Blog - Leveraging ILMerge to simplify deployment and your users experience

ILMerge is one of those little-known gems that are an absolute must-have once you know how to apply them effectively to scenarios you didn't even think about.

Specifically, whenever you work on a multi-project solution that may also use external projects in turn, forcing your users to add (say) five assembly references just to your "entry point" library is clearly a bad experience. One example that comes to mind is Enterprise Library, where you add a minimum of 3 (IIRC) assembly references to use just about *any* block in isolation. If you use more than one, it quickly becomes quite a big list. Wouldn't you want to just give your users a single EnterpriseLibrary.dll?

Of course, you wouldn't do it if the price of that end-user simplicity was that you had to merge all your projects into a single one, complicating the dependency management and isolation between layers.

Also, if you use a bunch of external libraries, do you think your users care? Having a single Dll gives a feeling that "this is small, I can manage to take a dependency on this single library".

ILMerge to the rescue

The two scenarios are precisely ILMerge targets. It allows you to merge multiple assemblies into a single one, offering various options when doing so.

…”

Daniel’s post reminded me that it’s been a long time since I’ve posted about ILMerge and that I STILL want to incorporate its usage into my products. I really do like the idea of having a deliverable that’s a single file…

I like the post because he provides some real world samples, includes on MSBuild snips and provides some times on some little things that might come in handy (like the /internalize parameter).

 

Related Past Post XRef:
Automate ILMerge'ing - Using Project Attributes to mark an Assembly for merging and then MSBuild to ILMerge them...
Gilma - GUI for ILMerge Branched for .Net 2.0
VS2005 Power Toys Pack Installer
MSBuild and ILMerge
"Gilma - GUI for ILMerge Application"
ILMerge Updated
The Code Project - Merging .NET assemblies using ILMerge - .NET

Monday, October 08, 2007

Automate ILMerge'ing - Using Project Attributes to mark an Assembly for merging and then MSBuild to ILMerge them...

Scott Hanselman's ComputerZen.com - Mixing Languages in a Single Assembly in Visual Studio seamlessly with ILMerge and MSBuild

"...

What I really want is to be able to mark an assembly as merge-able and have it automatically merged in just because it's referenced.

Here's what I came up with. Thanks to Dan Moseley and Joshua Flanagan for their help. Thanks to Jomo Fisher for the Target File.

...

Looks like they are both in there. To refresh, if I want to merge in VB assemblies:

  • Change the referencing CSPROJ to import "IlMerge.CSharp.targets"
  • Add <IlMerge>True</IlMerge> to the references you want merged in.
  • Save, Reload, Build

C# and VB, living together, mass hysteria!"

This is pretty cool.

I really dig the thought of just adding an project attribute to my assembly projects and having them automatically ILMerged during the build (much more so than ILMerging in post-build events).

 

Related Past Post XRef:
AsmZip - Compressing and Hiding Assemblies/DLL's in your .Net EXE
Gilma - GUI for ILMerge Branched for .Net 2.0
VS2005 Power Toys Pack Installer
MSBuild and ILMerge
"Gilma - GUI for ILMerge Application"
ILMerge Updated
The Code Project - Merging .NET assemblies using ILMerge - .NET

Tuesday, August 07, 2007

AsmZip - Compressing and Hiding Assemblies/DLL's in your .Net EXE

Francesco's blog - Compressing and hiding DLLs

"I like the ability to extend the power of my applications by simply adding a reference to an assembly that contains the functions or the controls that I need. I like much less, however, the need to distribute and deploy many DLLs together with my executables. In this post I show a technique that I use to compress (nearly) all the DLLs of a Windows Forms application and "merge" them with the main EXE.

All the files you need are in this ZIP archive, which contains the AsmZip.exe utility (which you run from the command prompt) and two source files, Unzipper.cs and Unzipper.vb. I suggest that you copy the AsmZip utility in a directory listed on the system path, to run it easily.

..."

An interesting deployment approach, sort of the same, yet different from, ILMerge. 

I like that it compresses the DLL's, making the entire package smaller (but of course the EXE bigger).

The main EXE needs to be updated to include the provided UnZipper class (C# and VB.Net versions are provided)

For me, the most interesting thing about this is how it shows .Net's flexibility in loading assemblies.

(via /egilh - Compressing and hiding DLLs)

 

Related Past Post XRef:
Gilma - GUI for ILMerge Branched for .Net 2.0
VS2005 Power Toys Pack Installer
MSBuild and ILMerge
"Gilma - GUI for ILMerge Application"
ILMerge Updated
The Code Project - Merging .NET assemblies using ILMerge - .NET