What is it?
IlMerge is a small utility produced by Microsoft. It's free and you can download the last version in Microsoft Download Center. Before to start using it you have to install downloaded .msi package. After installation you could find ILMerge.exe file in folder c:\Program Files\Microsoft\ILMerge\ (or c:\Program Files (x86)\Microsoft\ILMerge\ for x64 OS).
Run it with /? from command line and you'll see the list of available options. For my version this list is:
Usage: ilmerge [/lib:directory]* [/log[:filename]] [/keyfile:filename [/delaysign]] [/internalize[:filename]] [/t[arget]:(library|exe|winexe)] [/closed] [/ndebug] [/ver:version] [/copyattrs [/allowMultiple] [/keepFirst]] [/xmldocs] [/attr:filename] [/targetplatform:<version>[,<platformdir>] | /v1 | /v1.1 | /v2 | /v4] [/useFullPublicKeyForReferences] [/wildcards] [/zeroPeKind] [/allowDup:type]* [/union] [/align:n] /out:filename <primary assembly> [<other assemblies>...]
Simple example of use:
"c:\Program Files\Microsoft\ILMerge\ILMerge.exe" "c:\InputApp.exe" "c:\InputLib.dll" /t:winexe /out:"c:\OutputApp.exe"
Where to use?
The main idea of using ILMerge is getting one file from banch of files. I mean if you have several files (libraries or application and libraries) and are interested to deliver the only one executable\library to user, then you can use ILMerge to combine all your stuff to one file.
When may you need it? Definitelly in case of getting one file for setup of your application. Users won't be happy if you suggest them to copy many files and run one of them to install your application. Probably they would like just get and run one .exe file to install application.
My experience
In some projects where I used ILMerge it worked great. But in one project I got problem during merge that I still cannot solve. The problems is when I try to do merge usin this ustility I get an error:
An exception occurred during merging:
ILMerge.Merge: The assembly 'MyAssembly' was not merged in correctly. It is still listed as an external reference in
the target assembly.
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
Possible reasons. By scaning internet I found that this error can appear if something from this list isn't true:
1. The language of assembly MyAssembly should have the same as programming language of another assemblies in merge set.
2. The assembly MyAssembly should be signed with the same key as another input files.
3. Added /closed attribute to merge to get 'transitive closure' (why so, see here)
4. Set MyAssembly as first assembly in list of input assemblies (why so, see here in answers).
And here I got surprise! If I set assembly as first file in input list then I'll get output file with type 'dll' even if parameter /t:winexe was specified in command line. Yes, default behavior is that type of output file equals the type of key file (that is exactly the first file in input list). But documentation says if 'target' parameter is specified then it should rewrite default behavior. Seems like it should work (in theory) so, but it doesn't.
I checked pp 1-4. Nothing did work out for me...
I still have some qustions about how several things in ILMerge work. But anyway I think it is nice utility that can be very useful for not big tasks and input files without complicated references between each other.
IlMerge is a small utility produced by Microsoft. It's free and you can download the last version in Microsoft Download Center. Before to start using it you have to install downloaded .msi package. After installation you could find ILMerge.exe file in folder c:\Program Files\Microsoft\ILMerge\ (or c:\Program Files (x86)\Microsoft\ILMerge\ for x64 OS).
Run it with /? from command line and you'll see the list of available options. For my version this list is:
Usage: ilmerge [/lib:directory]* [/log[:filename]] [/keyfile:filename [/delaysign]] [/internalize[:filename]] [/t[arget]:(library|exe|winexe)] [/closed] [/ndebug] [/ver:version] [/copyattrs [/allowMultiple] [/keepFirst]] [/xmldocs] [/attr:filename] [/targetplatform:<version>[,<platformdir>] | /v1 | /v1.1 | /v2 | /v4] [/useFullPublicKeyForReferences] [/wildcards] [/zeroPeKind] [/allowDup:type]* [/union] [/align:n] /out:filename <primary assembly> [<other assemblies>...]
Simple example of use:
"c:\Program Files\Microsoft\ILMerge\ILMerge.exe" "c:\InputApp.exe" "c:\InputLib.dll" /t:winexe /out:"c:\OutputApp.exe"
Where to use?
The main idea of using ILMerge is getting one file from banch of files. I mean if you have several files (libraries or application and libraries) and are interested to deliver the only one executable\library to user, then you can use ILMerge to combine all your stuff to one file.
When may you need it? Definitelly in case of getting one file for setup of your application. Users won't be happy if you suggest them to copy many files and run one of them to install your application. Probably they would like just get and run one .exe file to install application.
My experience
In some projects where I used ILMerge it worked great. But in one project I got problem during merge that I still cannot solve. The problems is when I try to do merge usin this ustility I get an error:
An exception occurred during merging:
ILMerge.Merge: The assembly 'MyAssembly' was not merged in correctly. It is still listed as an external reference in
the target assembly.
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
Possible reasons. By scaning internet I found that this error can appear if something from this list isn't true:
1. The language of assembly MyAssembly should have the same as programming language of another assemblies in merge set.
2. The assembly MyAssembly should be signed with the same key as another input files.
3. Added /closed attribute to merge to get 'transitive closure' (why so, see here)
4. Set MyAssembly as first assembly in list of input assemblies (why so, see here in answers).
And here I got surprise! If I set assembly as first file in input list then I'll get output file with type 'dll' even if parameter /t:winexe was specified in command line. Yes, default behavior is that type of output file equals the type of key file (that is exactly the first file in input list). But documentation says if 'target' parameter is specified then it should rewrite default behavior. Seems like it should work (in theory) so, but it doesn't.
I checked pp 1-4. Nothing did work out for me...
I still have some qustions about how several things in ILMerge work. But anyway I think it is nice utility that can be very useful for not big tasks and input files without complicated references between each other.
Комментариев нет:
Отправить комментарий