greenoldman
greenoldman

Reputation: 21082

How to merge assemblies of a WPF application?

I tried to use ILMerge on my WPF-based project (VS2010, Net4.0) but I couldn't make the merged executable to run. So I created two very simply projects

After compiling each project I get single executable file (so merging, does not really merge anything, it is just for test). Each executable works of course.

Then I "merge" each executable this way:

"C:\Program Files\Microsoft\ILMerge\ilmerge" 
    /targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319 
    /lib:c:\Windows\Microsoft.NET\Framework\v4.0.30319\wpf 
    /out:Merged.exe MyApplication.exe

(I made the call multiline just for SO readability). Ok, now console application is merged and runs as fine as before, the wpf application is merged without any errors but I cannot run it. I mean, I type

Merged.exe

Taskbar blinks, but nothing shows up -- no window, no error, nothing.

So how should I merge WPF app?

Upvotes: 6

Views: 5329

Answers (2)

Victor V.
Victor V.

Reputation: 46

If I understand correctly, you want to embedded all assemblies into one exe.

There is an amazing NuGet package called Costura.Fody. Merging assemblies could not be easier!

If you need to merge Resource DLLs, you are in luck! There is another NuGet that extends Costura.Fody called Resource.Embedder!

Upvotes: 2

saret
saret

Reputation: 2227

From what I know (and have experienced) ilmerge does not work correctly with WPF assemblies that have xaml resources embedded.

See this question for some possible solutions/alternatives

Upvotes: 4

Related Questions