Git Product home page Git Product logo

ilmerge's Introduction

ILMerge

NuGet

ILMerge is a utility that merges multiple .NET assemblies into a single assembly. It is freely available for use and is available as a NuGet package.

If you have any problems using it, please get in touch. (mbarnett at microsoft dot com). But first try reading the documentation.

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.

The current version is 3.0.29 (released on 10 April 2019). NOTE: There is no longer a version of ILMerge that runs in the v1.1 runtime.

ILMerge runs in the v4.0 .NET Runtime, but it is also able to merge assemblies from other framework versions using the /targetplatformoption. Please see the documentation. (However, it can merge PDB files only for v2 (and later) assemblies.)

Currently, ILMerge works only on Windows-based platforms. It does not yet support Rotor or Mono.

If you use ASP.NET v2.0, then it provides a tool (based on ILMerge) to combine assemblies created during precompilation. You can get more details from the ASP.NET web site.

Installation

As noted on the ilmerge NuGet page, the package can be installed from the Visual Studio environment. Expand the project container in the Solution Explorer view. Right click on references and select Manage NuGet Packages

NuGet References Setting

Ensure the Package source is set to nuget.org

NuGet Package source

Next, click on Tools - NuGet Package Manager - Package Manager Console. Ensure the Package source is also set to nuget.org

NuGet Pakage Manager Console source.PNG

To install for the project, use the Install-Package command:

Install-Package ilmerge -Version 3.0.29

Usage

MSBuild

ILMerge can be used in MSBuild using the NuGet package:

<Project Sdk="Microsoft.NET.Sdk">

  <ItemGroup>
    <PackageReference Include="ILMerge" Version="3.0.29" />
  </ItemGroup>

  <Target Name="ILMerge">
    <!-- the ILMergePath property points to the location of ILMerge.exe console application -->
    <Exec Command="$(ILMergeConsolePath) /out:Merged.dll File1.dll File2.dll" />
  </Target>

</Project>

Edit the project .csproj or .vbproj files (inside the respective <Project> .. </Project> tags, typically at the end of the file. If compiling for a specific target, use explicit directories such as Bin\x64\Release:

<ItemGroup>
    <PackageReference Include="ILMerge" Version="3.0.29" />
  </ItemGroup>

  <Target Name="ILMerge">
    <!-- the ILMergePath property points to the location of ILMerge.exe console application -->
    <Exec Command="$(ILMergeConsolePath) Bin\x64\Release\myapp.exe  /out:myapp.exe Bin\x64\Release\File1.dll Bin\x64\Release\File2.dll Bin\x64\Release\File3.dll " />
  </Target>

Although whitespace is usually ignored in XML files, in this case the exact text is processed as a DOS command, so to improve readability, use the carat ^ (shift 6) line extenders:

<ItemGroup>
    <PackageReference Include="ILMerge" Version="3.0.29" />
  </ItemGroup>

  <Target Name="ILMerge">
    <!-- the ILMergePath property points to the location of ILMerge.exe console application -->
    <Exec Command="$(ILMergeConsolePath) Bin\x64\Release\myapp.exe ^
    /out:myapp.exe ^
    Bin\x64\Release\File1.dll ^
    Bin\x64\Release\File2.dll ^ 
    Bin\x64\Release\File3.dll " />
  </Target>

The DOS dir /b option can be helpful in listing all of the dependencies:

dir bin\x64\Debug\*.dll /b

From Visual Studio Developer Command Prompt:

# Download/install the package reference
msbuild /t:Restore

# Run the ILMerge target
msbuild /t:ILMerge

To run ILMerge in a batch file:

The Visual Studio Developer Command Prompt is not needed here, as msbuild is not used.

@echo off

:: this script needs https://www.nuget.org/packages/ilmerge

:: set your target executable name (typically [projectname].exe)
SET APP_NAME=myapp.exe

:: Set build, used for directory. Typically Release or Debug
SET ILMERGE_BUILD=Debug

:: Set platform, typically x64
SET ILMERGE_PLATFORM=x64

:: set your NuGet ILMerge Version, this is the number from the package manager install, for example:
:: PM> Install-Package ilmerge -Version 3.0.29
:: to confirm it is installed for a given project, see the packages.config file
SET ILMERGE_VERSION=3.0.29

:: the full ILMerge should be found here:
SET ILMERGE_PATH=%USERPROFILE%\.nuget\packages\ilmerge\%ILMERGE_VERSION%\tools\net452
:: dir "%ILMERGE_PATH%"\ILMerge.exe

echo Merging %APP_NAME% ...

:: add project DLL's starting with replacing the FirstLib with this project's DLL
"%ILMERGE_PATH%"\ILMerge.exe Bin\%ILMERGE_PLATFORM%\%ILMERGE_BUILD%\%APP_NAME%  ^
  /lib:Bin\%ILMERGE_PLATFORM%\%ILMERGE_BUILD%\ ^
  /out:%APP_NAME% ^
  FirstLib.dll ^
  mylib1.dll ^
  Microsoft.lib2.dll ^
  SomeOtherLib.dll ^
  \otherlibdir\otherlib.dll 


:Done
dir %APP_NAME%

ilmerge's People

Contributors

carlosmiei avatar gojimmypi avatar icnocop avatar jnm2 avatar logerfo avatar mike-barnett avatar naitp avatar perlun avatar porges avatar pzhlkj6612 avatar sunahe avatar terrajobst avatar vocero avatar zscn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ilmerge's Issues

Remove dependency on .NET 3.5

Currently ILMerge depends on .NET 3.5. I don't know how/why (the executable targets .NET 4.5.2), but the fact is it doesn't work without it.

This should be fixed; .NET 3.5 is 10 years old and completely obsolete. In the meantime, it should at least be documented somewhere.

Install-Package : Package 'ilmerge 3.0.21' is not found

I installed Visual Studio 2019 today, and tried to add the ILMerge tool using Install-Package ilmerge -Version 3.0.21 and received a Install-Package : Package 'ilmerge 3.0.21' is not found error.

image

Here's the full log of install attempt:

Each package is licensed to you by its owner. NuGet is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.

Package Manager Console Host Version 5.0.0.5917

Type 'get-help NuGet' to see all available NuGet commands.

PM> Install-Package ilmerge -Version 3.0.21


Attempting to gather dependency information for package 'ilmerge.3.0.21' with respect to project 'myprojectname', targeting '.NETFramework,Version=v4.6.2'
Install-Package : Package 'ilmerge 3.0.21' is not found in the following primary source(s): 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'. Please 
verify all your online package sources are available (OR) package id, version are specified correctly.
At line:1 char:1
+ Install-Package ilmerge -Version 3.0.21
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Time Elapsed: 00:00:01.0570615
PM> 

There's this year-old open issue for NuGet: NuGet/Home#1827 I cleared the cache as suggested, but no luck.

image

Does ILMerge work with Visual Studio 2019, or are there other ideas on how to make a single, stand-alone, portable exe file without needing all the other DLL's in the same directory?

Signing with /keyfile throws an error

In my experience, signing anything with /keyfile but not specifying /delaysign results in seeing an error message:

ILMerge error: The target assembly was not able to be strongly named (did you forget to use the /delaysign option?)."),"There was an error in the log output from signing the assembly with a keyfile

Based on how I've used early versions of ILMerge this seems like a bug to me. When I drill down into the log file I can see another error:

The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

I've seen this on a few different machines running Windows 7 using different combinations of dll and snk files. I've also been able to reproduce this issue with a unit test that can be found here.

Could not find file or assembly "x" on runtime.

I merged multiple .dlls and an .exe of a CL-Tool I have been working on so it can be easily distributable.

The merging itself works and throws no errors, but when I go to call a command on the exe, so
"app command -option value" and it immediately gives me an error that some File or Assembly (which the .exe has been merged with, I checked with ILSpy so it is in there and the log says so too) could not be found.

I tried using the closed option, but it didn't change anything.

Is there anything obvious I have missed?

Docs: convert .doc file to Markdown

Hi,

Have been using ILMerge for years, thanks for an excellent tool. Didn't know until now that it has been open sourced, great work @mike-barnett and the other people at Microsoft. 😄

I have a small suggestion: the documentation is currently available as a Word file. This makes it a little bit more awkward to consume. Markdown has taken over the world since this project was created, and converting this document to Markdown would make it a lot more accessible via the web browser etc.

This issue exists to discuss the matter. Would you accept a PR that converts the documentation to Markdown, or would you like to fix it yourself, or do you consider it a stupid idea or...? 😉

An attempt was made to load a program with an incorrect format

ILMerge fails with the following log:

ILMerge version 2.14.1208.65535
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /keyfile:..\FakeItEasy.snk /lib:bin\Release\net45\ /targetplatform:v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5 /internalize:..\ILMerge.Internalize.Exclude.txt /out:bin\Release\net45\FakeItEasy.dll /log:bin\Release\net45\ILMerge.log obj\Release\net45\FakeItEasy.dll bin\Release\net45\Castle.Core.dll 
Set platform to 'v4', using directory 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5' for mscorlib.dll
Running on Microsoft (R) .NET Framework v4.0.30319
mscorlib.dll version = 4.0.0.0
Read 6 lines from the exclusion file '..\ILMerge.Internalize.Exclude.txt'.
The list of input assemblies is:
	obj\Release\net45\FakeItEasy.dll
	bin\Release\net45\Castle.Core.dll
Trying to read assembly from the file 'D:\Git\FakeItEasy\src\FakeItEasy\obj\Release\net45\FakeItEasy.dll'.
	Successfully read in assembly.
	There were no errors reported in FakeItEasy's metadata.
Trying to read assembly from the file 'D:\Git\FakeItEasy\src\FakeItEasy\bin\Release\net45\Castle.Core.dll'.
Can not find PDB file. Debug info will not be available for assembly 'bin\Release\net45\Castle.Core.dll'.
	Successfully read in assembly.
	There were no errors reported in Castle.Core's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
	FakeItEasy.PeKind = ILonly
	Castle.Core.PeKind = ILonly
All input assemblies have a compatible PeKind value.
AssemblyResolver: Assembly 'FakeItEasy' is referencing assembly 'System.Core'.
	AssemblyResolver: Attempting referencing assembly's directory.
	AssemblyResolver: Did not find assembly in referencing assembly's directory.
	AssemblyResolver: Attempting input directory.
	AssemblyResolver: Did not find assembly in input directory.
	AssemblyResolver: Attempting user-supplied directories.
	AssemblyResolver: Did not find assembly in user-supplied directories.
	AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Core'.
Resolved assembly reference 'System.Core' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll'. (Used framework directory.)
Using assembly 'FakeItEasy' for assembly-level attributes for the target assembly.
Merging assembly 'FakeItEasy' into target assembly.
Merging assembly 'Castle.Core' into target assembly.
Duplicate type name: modifying name of the type '<>f__AnonymousType0`2' (from assembly 'Castle.Core') to 'Castle.Core.<>f__AnonymousType0`2'
Duplicate type name: modifying name of the type '<>f__AnonymousType1`2' (from assembly 'Castle.Core') to 'Castle.Core.<>f__AnonymousType1`2'
Copying 1 Win32 Resources from assembly 'FakeItEasy' into target assembly.
ILMerge: Signing assembly with the key file '..\FakeItEasy.snk'.
	There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'bin\Release\net45\FakeItEasy.dll'.
AssemblyResolver: Assembly 'Castle.Core' is referencing assembly 'System.Configuration'.
	AssemblyResolver: Attempting referencing assembly's directory.
	AssemblyResolver: Did not find assembly in referencing assembly's directory.
	AssemblyResolver: Attempting input directory.
	AssemblyResolver: Did not find assembly in input directory.
	AssemblyResolver: Attempting user-supplied directories.
	AssemblyResolver: Did not find assembly in user-supplied directories.
	AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Configuration'.
Resolved assembly reference 'System.Configuration' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Configuration.dll'. (Used framework directory.)
An exception occurred during merging:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at System.Compiler.Writer.MscorsnStrongNameSignatureGeneration(String wszFilePath, String wszKeyContainer, Byte[] pbKeyBlob, Int32 cbKeyBlob, IntPtr ppbSignatureBlob, IntPtr pcbSignatureBlob)
   at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
   at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

Note that this started happening only after I reset my Windows install. Everything else seems to be working fine, I can build other projects without problems. Only ILMerge seems to be having issues.

What could be causing this? I very much doubt that System.Configuration is a program with an incorrect format... Nothing would be working if it was.

Is it possible to use ILMerge with Structuremap or other typescanning utility?

I am trying to create a portable console application that has no dependent dlls, so I found ILMerge which does the trick. However when trying to incorporate structuremap the scanning functionality of the registry does not seem to be working. Exception below.

An unhandled exception of type 'System.TypeLoadException' occurred in mscorlib.dll

Additional information: Could not load type '<MediatR-IRequestHandler<TRequest,MediatR-Unit>-Handle>d__0' from assembly 'queue, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the parent does not exist.

I am using a another nuget package called MediatR which exposes some types that I would assume should now be bundled into my assembly.

Just curious if this is supported and I am doing something wrong or if ILMerge does not support this. Thanks!

The structuremap registry is simple:

Scan(x =>
{
    x.AssembliesAndExecutablesFromApplicationBaseDirectory();

    x.ConnectImplementationsToTypesClosing(typeof(IRequestHandler<,>));
});

Instructions for MSBuild in the main readme.md are wrong.

Per the current readme.md:

<ItemGroup>
    <PackageReference Include="ILMerge" Version="2.15.0" />
  </ItemGroup>

  <Target Name="ILMerge">
    <!-- the ILMergePath property points to the location of ILMerge.exe console application -->
    <Exec Command="$(ILMergeConsolePath) /out:Merged.dll File1.dll File2.dll" />
</Target>

This has multiple problems... :-/
1.) The latest version of the package on the NuGet gallery is only 2.14.1208 -- so, the package reference fails.

2.) Even after updating the package reference, the ILMerge target will fail, because $(ILMergeConsolePath) is not defined (is there a targets file we need to import??)

3.) The comment refers to the property is the "ILMergePath" property (instead of ILMergeConsolePath) -- which is also not defined.

mixed mode assemblies

As far as I know ILMerge does not accept mixed mode assemblies, those containing unmanaged code. I have some assemblies created using C+/CLI and would like to merge them. I am wondering if extending ILMerge to handle assemblies like this is possible, even if there is only a single mixed mode assembly. I am happy to do the work for this if possible but would require some guidance, at present I am reading ECMA 335 and have downloaded and built ILMerge and am going to step through the existing code. However I don't want to spend too much time if this is simply not doable or would not be merged. If it is possible any pointers to things to read first would be gladly recieved.

ILMerge loses SourceLink information

I'm trying to use SourceLink to enable source stepping. I can see that the original pdb contains SourceLink information (mapping from local directory to GitHub), but after ILMerge the new PDB no longer contains this information. Is there a way to preserve it?

Error message allowDup parameter misspelled

Can you fix the following error message to say allowDup instead of alllowDup?

ILMerge.Merge: ERROR!!: Duplicate type 'Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances' found in assembly 'Microsoft.Build.Tasks.Core'. Do you want to use the /alllowDup option?

Support for portable PDBs

With the new csproj format, the default is the superior portable PDB format for all .NET projects, including traditional .NET Framework apps.

ILMerge will crash with

An exception occurred during merging:
ILMerge.Merge:        There were errors reported in ReferencedProject's metadata.
      Array dimensions exceeded supported range.
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

as demonstrated by this simple test:
master...jnm2:portable_pdb_bug

This is somewhat of a integral issue. Where should this capability be on the roadmap?

Inconsistent MSBuild property in readme

README.md has these lines:

<!-- the ILMergePath property points to the location of ILMerge.exe console application -->
<Exec Command="$(ILMergeConsolePath) /out:Merged.dll File1.dll File2.dll" />

The comment refers to ILMergePath, which does not exist on the Exec line.

I got the impression that something created one of the properties for you. Only after understanding the cryptic error messages that result from failing to specify the property myself did I realize that I needed to.

WindowsForm Titlebar and Borders shrink

Hello,

I merge my assamblies using the nuget package.
Since I do that, all Windows Forms with BorderStyle-Property "FixedToolWindow" or "FixedSingle" or "FixedDialog" have a smaller Title Bar and a bit smaller Border Size then normal.

This is how it looks before merge with ILMerge (BorderStyle = FixedDialog):
https://i.imgur.com/2jZ11yh.png

And this is how it looks after ILMerge (BorderStyle = FixedDialog):
https://i.imgur.com/WhB6vVn.png

I am using Visual Studio 2017 on Windows 10. My projects using .Net Framework 4.5.

Do you have any ID how to solve the problem easlily?

Thanks

Command line documentation does not appear to be correct.

1.) According to the command line documentation, it sounds like "/closed" will automatically merge direct and indirect references into the executable. That does not appear to be the case.

2.) According to the command line documentation /internalize:"path\to\file.dll" should cause the file to be excluded, but that also does not appear to be the case.

3.) Additionally, the output (warning?) message that a non-.net assembly will be skipped, but the rest of the arguments will be processed, is a giant lie. -- it literally just stops and doesn't do anything.

This command demonstrates the first behavior:

"D:\path\to\ILMerge.exe" /closed /out:"D:\temp\derp\merged.exe" "D:\TEMP\FOOP\input.exe"

Input.exe has over 200 references, and combined they're over 120 MB... but the resulting output file is only 12 KB, and launching it as a standalone generates an error about missing references, immediately.

This command demonstrates the second two behaviors:

"d:\path\to\ILMerge.exe" /wildcards /internalize:"D:\TEMP\FOOP\DocumentDB.Spatial.Sql.dll" /closed /out:"D:\temp\derp\merged.exe" "D:\TEMP\FOOP\Input.exe" "D:\TEMP\FOOP\*.dll"
An exception occurred during merging:
ILMerge.Merge: Could not load assembly from the location 'D:\TEMP\FOOP\DocumentDB.Spatial.Sql.dll'.
Skipping and processing rest of arguments.
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

Even though it says it will skip that file and keep going, it doesn't; it just stops, it doesn't even output the exe with the missing references (like the first command does). -- Secondly, the exclude directive ("internalize") has no effect. It's clearly still trying to include that file. :(

Is there any alternative to make this work? -- I really don't want to have to add ~270 input files to the command!!

ILMerge fails to properly merge WpfMath

Repository https://github.com/davidagross/ILMerge-vs-WpfMath provides a MWE of this error.

Basically, when WpfMath.dll isn't next to the merged, standalone executable, the render fails:

System.TypeInitializationException: The type initializer for 'WpfMath.DefaultTexFont' threw an exception. ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo)
   at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr)
   at MS.Internal.Text.TextInterface.Factory.CreateFontFace(Uri filePathUri, UInt32 faceIndex, FontSimulations fontSimulationFlags)
   at System.Windows.Media.GlyphTypeface.Initialize(Uri typefaceSource, StyleSimulations styleSimulations)
   at WpfMath.DefaultTexFontParser.CreateFont(String name)
   at WpfMath.DefaultTexFontParser.GetFontDescriptions()
   at WpfMath.DefaultTexFont..cctor()
   --- End of inner exception stack trace ---
   at WpfMath.DefaultTexFont..ctor(Double size)
   at WpfMath.TexFormula.GetRenderer(TexStyle style, Double scale, String systemTextFontName)
   at WpfMath.Extensions.RenderToPng(TexFormula texForm, Double scale, Double x, Double y, String systemTextFontName)
   at ILMerge_vs_WpfMath.Renderer.DisplayEquation()
   at ILMerge_vs_WpfMath.Renderer..ctor()

indicating that the merge was not successfull. This is also tracked in ForNeVeR/xaml-math#202.

Fail to load plugin in Console application merged with ILMerge

I merged a Console application that reference a class libray mylib.dll in net45 with ILMerge utility.

The Console application load plugin(s) at runtime that implement an Interface.

The plugin reference the same class library mylib.dll that is used by console.exe

If I run the console application without merge, it can load the plugin successfully.

The merge command

ilmerge /out:"outdir\console.exe" console.exe *.dll 
    /target:exe /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 /wildcards /ndebug 

But When merging the console application with all its dependencies using ILMerge, the plugin can't be loaded and raise an exception:

Loader Exception: System.IO.FileNotFoundException: Could not load file or assembly 'mylib.dll, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'mylib.dll, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null'

The question:
As the assemply mylib.dll is merged in exe, is there a way to extract that assemply at runtime and load it using the event AppDomain.CurrentDomain.AssemblyResolve

Key needs to be greater than 0.

Hi, I have issue with ilmerge it fail with exception provided below.
I can`t provide reproducible test case, it seems to be related to assembly size ilmerge process.
I trying to process ~20mb binaries.
I think that problem related to Node.UniqueKey exhaustion. In method https://github.com/Microsoft/ILMerge/blob/96717bd5cd3b06b08a3353ea8e8dc36160641f12/System.Compiler/Nodes.cs#L2443 new key for node generated by adding 17 to previous key, if I change constant to 13 ilmerge work fine.
Please advise how may I fix this problem.

Имя параметра: key
в System.Compiler.TrivialHashtable.get_Item(Int32 key)
в System.Compiler.Ir2md.GetTypeSpecIndex(TypeNode type)
в System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
в System.Compiler.Ir2md.GetMemberRefIndex(Member m)
в System.Compiler.Ir2md.GetFieldToken(Field f)
в System.Compiler.Ir2md.VisitMemberBinding(MemberBinding memberBinding)
в System.Compiler.Ir2md.Visit(Node node)
в System.Compiler.Ir2md.VisitReturn(Return Return)
в System.Compiler.Ir2md.Visit(Node node)
в System.Compiler.Ir2md.VisitBlock(Block block)
в System.Compiler.Ir2md.Visit(Node node)
в System.Compiler.Ir2md.VisitBlock(Block block)
в System.Compiler.Ir2md.VisitMethodBody(Method method)
в System.Compiler.Ir2md.VisitMethod(Method method)
в System.Compiler.Ir2md.Visit(Node node)
в System.Compiler.Ir2md.VisitClass(Class Class)
в System.Compiler.Ir2md.Visit(Node node)
в System.Compiler.Ir2md.VisitModule(Module module)
в System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
в System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
в System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
в System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
в ILMerging.ILMerge.Merge()
в ILMerging.ILMerge.Main(String[] args)

Windows 10 - install ilmerge.3.0.21.nupkg fails

Hi,
I'm trying to install ilmerge.3.0.21.nupkg.

I want the ilmerge.exe.

It fails with:
_C:\temp>nuget install ilmerge.3.0.21.nupkg
Feeds used:
https://api.nuget.org/v3/index.json

Installing package 'ilmerge.3.0.21.nupkg' to 'C:\temp\AWS-CFN-Build\Release'.
GET https://api.nuget.org/v3/registration3-gz-semver2/ilmerge.3.0.21.nupkg/index.json
NotFound https://api.nuget.org/v3/registration3-gz-semver2/ilmerge.3.0.21.nupkg/index.json 907ms
Unable to find package 'ilmerge.3.0.21.nupkg'_

Can some please tell me how to fix this?

I'm using Windows 10.
I got ilmerge from:
https://www.nuget.org/packages/ilmerge

Ignore specific input PDBs

This issues is a request for a temporary workaround for issues with ILMerge where it cannot process the new portable .NET PDB format. Can a option be added to ILMerge to ignore one or more input PDB(s) so as to avoid processing a known PDB that's in the portable format?

StackOverflowException and OutOfMemory Exception

When I run in release mode I get a stackoverflowexception. If I run in debug mode and break I see lots of OutOfMemory exceptions due to trying to allocate an array >2 gb

I ran with the log options and here is the resultant log.

=============================================
Timestamp (UTC): 4/06/2019 3:14:15 AM
ILMerge version 3.0.0.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge company.editor.exe /log /lib:C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated /out:company.exe company.model.dll company.common.dll company.ui.common.dll company.j2534.dll company.external.dll company.api.dll
Set platform to 'v4', using directory 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319' for mscorlib.dll
Running on Microsoft (R) .NET Framework v4.0.30319
mscorlib.dll version = 4.0.0.0
The list of input assemblies is:
        company.editor.exe
        company.model.dll
        company.common.dll
        company.ui.common.dll
        company.j2534.dll
        company.external.dll
        company.api.dll
Trying to read assembly from the file 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\company.editor.exe'.
Can not find PDB file. Debug info will not be available for assembly 'company.editor.exe'.
        Successfully read in assembly.
        There were no errors reported in company.Editor's metadata.
Trying to read assembly from the file 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\company.model.dll'.
Can not find PDB file. Debug info will not be available for assembly 'company.model.dll'.
        Successfully read in assembly.
        There were no errors reported in company.Model's metadata.
Trying to read assembly from the file 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\company.common.dll'.
Can not find PDB file. Debug info will not be available for assembly 'company.common.dll'.
        Successfully read in assembly.
        There were no errors reported in company.Common's metadata.
Trying to read assembly from the file 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\company.ui.common.dll'.
Can not find PDB file. Debug info will not be available for assembly 'company.ui.common.dll'.
        Successfully read in assembly.
        There were no errors reported in company.UI.Common's metadata.
Trying to read assembly from the file 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\company.j2534.dll'.
Can not find PDB file. Debug info will not be available for assembly 'company.j2534.dll'.
        Successfully read in assembly.
        There were no errors reported in company.J2534's metadata.
Trying to read assembly from the file 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\company.external.dll'.
Can not find PDB file. Debug info will not be available for assembly 'company.external.dll'.
        Successfully read in assembly.
        There were no errors reported in company.External's metadata.
Trying to read assembly from the file 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\company.api.dll'.
Can not find PDB file. Debug info will not be available for assembly 'company.api.dll'.
        Successfully read in assembly.
        There were no errors reported in company.Api's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
        company.Editor.PeKind = ILonly, Requires32bits, Prefers32bits
        company.Model.PeKind = ILonly
        company.Common.PeKind = ILonly
        company.UI.Common.PeKind = ILonly
        company.J2534.PeKind = ILonly
        company.External.PeKind = ILonly
        company.Api.PeKind = ILonly
All input assemblies have a compatible PeKind value.
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'PresentationFramework'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
        AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'PresentationFramework' is referencing assembly 'WindowsBase'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
        AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'PresentationFramework' is referencing assembly 'System.Xaml'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Xaml'.
Resolved assembly reference 'System.Xaml' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Xaml.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'DevExpress.Xpf.Core.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.Core.v19.1'.
Resolved assembly reference 'DevExpress.Xpf.Core.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.Core.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'PresentationFramework' is referencing assembly 'PresentationCore'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
        AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'DevExpress.Xpf.Grid.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.Grid.v19.1'.
Resolved assembly reference 'DevExpress.Xpf.Grid.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.Grid.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.Grid.v19.1' is referencing assembly 'DevExpress.Xpf.Grid.v19.1.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.Grid.v19.1.Core'.
Resolved assembly reference 'DevExpress.Xpf.Grid.v19.1.Core' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.Grid.v19.1.Core.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'DevExpress.Mvvm.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Mvvm.v19.1'.
Resolved assembly reference 'DevExpress.Mvvm.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Mvvm.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.Grid.v19.1' is referencing assembly 'DevExpress.Data.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Data.v19.1'.
Resolved assembly reference 'DevExpress.Data.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Data.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.Grid.v19.1' is referencing assembly 'DevExpress.Printing.v19.1.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Printing.v19.1.Core'.
Resolved assembly reference 'DevExpress.Printing.v19.1.Core' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Printing.v19.1.Core.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'DevExpress.Xpf.Docking.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.Docking.v19.1'.
Resolved assembly reference 'DevExpress.Xpf.Docking.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.Docking.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.Docking.v19.1' is referencing assembly 'DevExpress.Xpf.Layout.v19.1.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.Layout.v19.1.Core'.
Resolved assembly reference 'DevExpress.Xpf.Layout.v19.1.Core' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.Layout.v19.1.Core.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'System.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Core'.
Resolved assembly reference 'System.Core' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Core.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'DevExpress.Xpf.Controls.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.Controls.v19.1'.
Resolved assembly reference 'DevExpress.Xpf.Controls.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.Controls.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'DevExpress.Xpf.Charts.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.Charts.v19.1'.
Resolved assembly reference 'DevExpress.Xpf.Charts.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.Charts.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.Charts.v19.1' is referencing assembly 'DevExpress.Charts.v19.1.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Charts.v19.1.Core'.
Resolved assembly reference 'DevExpress.Charts.v19.1.Core' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Charts.v19.1.Core.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'Arction.WPF.Gauges'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Arction.WPF.Gauges'.
Resolved assembly reference 'Arction.WPF.Gauges' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Arction.WPF.Gauges.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'Arction.Wpf.SemibindableCharting.LightningChartUltimate'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Arction.Wpf.SemibindableCharting.LightningChartUltimate'.
Resolved assembly reference 'Arction.Wpf.SemibindableCharting.LightningChartUltimate' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Arction.Wpf.SemibindableCharting.LightningChartUltimate.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'Nito.AsyncEx'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Nito.AsyncEx'.
Resolved assembly reference 'Nito.AsyncEx' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Nito.AsyncEx.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'Nito.AsyncEx' is referencing assembly 'System.Runtime'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Runtime'.
Resolved assembly reference 'System.Runtime' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Runtime.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'SharpRaven'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'SharpRaven'.
Resolved assembly reference 'SharpRaven' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\SharpRaven.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Model' is referencing assembly 'protobuf-net'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'protobuf-net'.
Resolved assembly reference 'protobuf-net' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\protobuf-net.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Model' is referencing assembly 'System.ComponentModel.DataAnnotations'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.ComponentModel.DataAnnotations'.
Resolved assembly reference 'System.ComponentModel.DataAnnotations' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.ComponentModel.DataAnnotations.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'company.Model' is referencing assembly 'LiteDB'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'LiteDB'.
Resolved assembly reference 'LiteDB' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\LiteDB.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Model' is referencing assembly 'System.Runtime.Serialization'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Runtime.Serialization'.
Resolved assembly reference 'System.Runtime.Serialization' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Runtime.Serialization.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'company.Common' is referencing assembly 'Unity.Container'.
        AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'Unity.Container' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Unity.Container.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'Unity.Container' is referencing assembly 'Unity.Abstractions'.
        AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'Unity.Abstractions' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Unity.Abstractions.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.UI.Common' is referencing assembly 'DevExpress.Xpf.PdfViewer.v19.1'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.PdfViewer.v19.1'.
Resolved assembly reference 'DevExpress.Xpf.PdfViewer.v19.1' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.PdfViewer.v19.1.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.PdfViewer.v19.1' is referencing assembly 'DevExpress.Xpf.DocumentViewer.v19.1.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Xpf.DocumentViewer.v19.1.Core'.
Resolved assembly reference 'DevExpress.Xpf.DocumentViewer.v19.1.Core' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Xpf.DocumentViewer.v19.1.Core.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.PdfViewer.v19.1' is referencing assembly 'DevExpress.Pdf.v19.1.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'DevExpress.Pdf.v19.1.Core'.
Resolved assembly reference 'DevExpress.Pdf.v19.1.Core' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\DevExpress.Pdf.v19.1.Core.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.UI.Common' is referencing assembly 'Arction.Wpf.BindableCharting.LightningChartUltimate'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Arction.Wpf.BindableCharting.LightningChartUltimate'.
Resolved assembly reference 'Arction.Wpf.BindableCharting.LightningChartUltimate' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Arction.Wpf.BindableCharting.LightningChartUltimate.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Api' is referencing assembly 'HtmlAgilityPack'.
        AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'HtmlAgilityPack' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\HtmlAgilityPack.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Api' is referencing assembly 'System.Net.Http'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Net.Http'.
Resolved assembly reference 'System.Net.Http' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\System.Net.Http.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Api' is referencing assembly 'SendGrid'.
        AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'SendGrid' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\SendGrid.dll'. (Used referencing Module's directory.)
Using assembly 'company.Editor' for assembly-level attributes for the target assembly.
Merging assembly 'company.Editor' into target assembly.
Merging assembly 'company.Model' into target assembly.
Duplicate type name: modifying name of the type '<>F{00000008}`5' (from assembly 'company.Model') to 'company.Model.<>F{00000008}`5'
Duplicate type name: modifying name of the type '<PrivateImplementationDetails>' (from assembly 'company.Model') to 'company.Model.<PrivateImplementationDetails>'
Merging assembly 'company.Common' into target assembly.
Duplicate type name: modifying name of the type '<PrivateImplementationDetails>' (from assembly 'company.Common') to 'company.Common.<PrivateImplementationDetails>'
Merging assembly 'company.UI.Common' into target assembly.
Merging assembly 'company.J2534' into target assembly.
Duplicate type name: modifying name of the type '<PrivateImplementationDetails>' (from assembly 'company.J2534') to 'company.J2534.<PrivateImplementationDetails>'
Merging assembly 'company.External' into target assembly.
Duplicate type name: modifying name of the type '<PrivateImplementationDetails>' (from assembly 'company.External') to 'company.External.<PrivateImplementationDetails>'
Merging assembly 'company.Api' into target assembly.
Copying 9 Win32 Resources from assembly 'company.Editor' into target assembly.
Transferring entry point 'company.Editor.App.Main' from assembly 'company.Editor' to assembly 'company'.
        There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'company.exe'.
AssemblyResolver: Assembly 'PresentationCore' is referencing assembly 'UIAutomationTypes'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
        AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'Arction.Wpf.SemibindableCharting.LightningChartUltimate' is referencing assembly 'Arction.RenderingDefinitions'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Arction.RenderingDefinitions'.
Resolved assembly reference 'Arction.RenderingDefinitions' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Arction.RenderingDefinitions.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'Arction.Wpf.SemibindableCharting.LightningChartUltimate' is referencing assembly 'Arction.Licensing'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Arction.Licensing'.
Resolved assembly reference 'Arction.Licensing' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Arction.Licensing.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'Arction.Wpf.SemibindableCharting.LightningChartUltimate' is referencing assembly 'Arction.RenderingEngine'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Arction.RenderingEngine'.
Resolved assembly reference 'Arction.RenderingEngine' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Arction.RenderingEngine.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'Arction.Wpf.SemibindableCharting.LightningChartUltimate' is referencing assembly 'Arction.DirectX'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Arction.DirectX'.
Resolved assembly reference 'Arction.DirectX' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Arction.DirectX.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'System.Configuration'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Configuration'.
Resolved assembly reference 'System.Configuration' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Configuration.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'DevExpress.Xpf.Grid.v19.1.Core' is referencing assembly 'System.Printing'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
        AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'DevExpress.Xpf.Grid.v19.1.Core' is referencing assembly 'UIAutomationProvider'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
        AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'company.Editor' is referencing assembly 'Microsoft.CSharp'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'Microsoft.CSharp'.
Resolved assembly reference 'Microsoft.CSharp' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\Microsoft.CSharp.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'Nito.AsyncEx' is referencing assembly 'System.Threading.Tasks'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Threading.Tasks'.
Resolved assembly reference 'System.Threading.Tasks' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Threading.Tasks.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'Nito.AsyncEx' is referencing assembly 'System.Diagnostics.Debug'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Diagnostics.Debug'.
Resolved assembly reference 'System.Diagnostics.Debug' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Diagnostics.Debug.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'SharpRaven' is referencing assembly 'Newtonsoft.Json'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Newtonsoft.Json'.
Resolved assembly reference 'Newtonsoft.Json' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Newtonsoft.Json.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Model' is referencing assembly 'CoreTechs.Common'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'CoreTechs.Common'.
Resolved assembly reference 'CoreTechs.Common' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\CoreTechs.Common.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Model' is referencing assembly 'MoreLinq'.
        AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'MoreLinq' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\MoreLinq.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'MoreLinq' is referencing assembly 'System.ValueTuple'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'System.ValueTuple'.
Resolved assembly reference 'System.ValueTuple' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\System.ValueTuple.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Common' is referencing assembly 'ICSharpCode.SharpZipLib'.
        AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'ICSharpCode.SharpZipLib' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\ICSharpCode.SharpZipLib.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Api' is referencing assembly 'System.Net.Http.WebRequest'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Net.Http.WebRequest'.
Resolved assembly reference 'System.Net.Http.WebRequest' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.Net.Http.WebRequest.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'System.Net.Http.WebRequest' is referencing assembly 'System.Net.Http'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Net.Http'.
Resolved assembly reference 'System.Net.Http' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Net.Http.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Api' is referencing assembly 'GoogleAnalyticsTracker.Simple'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'GoogleAnalyticsTracker.Simple'.
Resolved assembly reference 'GoogleAnalyticsTracker.Simple' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\GoogleAnalyticsTracker.Simple.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'GoogleAnalyticsTracker.Simple' is referencing assembly 'GoogleAnalyticsTracker.Core'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'GoogleAnalyticsTracker.Core'.
Resolved assembly reference 'GoogleAnalyticsTracker.Core' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\GoogleAnalyticsTracker.Core.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Api' is referencing assembly 'WebApiContrib.Formatting.ProtoBuf'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'WebApiContrib.Formatting.ProtoBuf'.
Resolved assembly reference 'WebApiContrib.Formatting.ProtoBuf' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\WebApiContrib.Formatting.ProtoBuf.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'WebApiContrib.Formatting.ProtoBuf' is referencing assembly 'System.Net.Http.Formatting'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Net.Http.Formatting'.
Resolved assembly reference 'System.Net.Http.Formatting' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\System.Net.Http.Formatting.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'WebApiContrib.Formatting.ProtoBuf' is referencing assembly 'System.Net.Http'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Net.Http'.
Resolved assembly reference 'System.Net.Http' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\System.Net.Http.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'WebApiContrib.Formatting.ProtoBuf' is referencing assembly 'protobuf-net'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'protobuf-net'.
Resolved assembly reference 'protobuf-net' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\protobuf-net.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'System.Net.Http.Formatting' is referencing assembly 'Newtonsoft.Json'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Newtonsoft.Json'.
Resolved assembly reference 'Newtonsoft.Json' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Newtonsoft.Json.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'SendGrid' is referencing assembly 'Newtonsoft.Json'.
        AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'Newtonsoft.Json'.
Resolved assembly reference 'Newtonsoft.Json' to 'C:\Temp\company\UI\company.Editor\bin\Debug - Editor - Obfuscated\Newtonsoft.Json.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'company.Api' is referencing assembly 'System.DirectoryServices.AccountManagement'.
        AssemblyResolver: Attempting referencing assembly's directory.
        AssemblyResolver: Did not find assembly in referencing assembly's directory.
        AssemblyResolver: Attempting input directory.
        AssemblyResolver: Did not find assembly in input directory.
        AssemblyResolver: Attempting user-supplied directories.
        AssemblyResolver: Did not find assembly in user-supplied directories.
        AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.DirectoryServices.AccountManagement'.
Resolved assembly reference 'System.DirectoryServices.AccountManagement' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\..\v4.0.30319\System.DirectoryServices.AccountManagement.dll'. (Used framework directory.)

Process is terminated due to StackOverflowException.

IlMerge GUI

is it possible to put IlMerge GUI somewhere on the web too?
the one on codeplex is gonna be out soon, right?

Unresolved assembly reference not allowed: System.Core

Every time I try to merge any assembly, I am presented with the following exception:

An exception occurred during merging:
Unresolved assembly reference not allowed: System.Core.
   at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
   at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
   at System.Compiler.Ir2md.WriteTypeDefOrRefEncoded(BinaryWriter target, TypeNode type)
   at System.Compiler.Ir2md.WriteTypeSignature(BinaryWriter target, TypeNode type, Boolean instantiateGenericTypes)
   at System.Compiler.Ir2md.WriteTypeSignature(BinaryWriter target, TypeNode type, Boolean instantiateGenericTypes)
   at System.Compiler.Ir2md.GetBlobIndex(TypeNode type)
   at System.Compiler.Ir2md.GetTypeSpecIndex(TypeNode type)
   at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
   at System.Compiler.Ir2md.GetMemberRefIndex(Member m)
   at System.Compiler.Ir2md.GetMethodToken(Method m)
   at System.Compiler.Ir2md.VisitConstruct(Construct cons)
   at System.Compiler.Ir2md.VisitAssignmentStatement(AssignmentStatement assignment)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitMethodBody(Method method)
   at System.Compiler.Ir2md.VisitMethod(Method method)
   at System.Compiler.Ir2md.VisitClass(Class Class)
   at System.Compiler.Ir2md.VisitModule(Module module)
   at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
   at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
   at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
   at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

The command line arguments I'm using look like this:
ilmerge.exe /out:Result.exe Input1.exe Input2.dll

I have tried multiple combinations of my assemblies and all of them produce this exception.
System.Core is a part of the .NET framework and I'm not specifying to merge this assembly.

No way to remove un-referenced code

It would be good if you could have ILMerge automatically remove all non-referenced code from non-primary assemblies (excluding ones specified with ExcludeFile)...
If I am merging in a 3rd party library with /Internalize (for example) why would I want all of the components in that library that I am not using?

OutOfMemoryException error when merging NodaTime

When I try to use ILMerge to merge a C# DLL that uses NodaTime, I get the following error:
1>[NuGet Packages Dir]\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets(87,5): error : ILMerge.Merge: There were errors reported in NodaTime's metadata.
1>[NuGet Packages Dir]\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets(87,5): error : Exception of type 'System.OutOfMemoryException' was thrown.

It seems like there is an error merging in NodaTime's PDB because the build is successful if I manually remove the NodaTime PDB. Another workaround is to set ILMergeDebugInfo option to false.

In my case I'm using VS2017, with a C# project targeting .NET 4.7. I use NuGet to pull in the NodaTime and ILMerge dependencies. The specific packages are:

  • NodaTime v2.2.1
  • ILMerge v2.13.307
  • MSBuild.ILMerge.Task v1.0.5

As a temporary workaround, is it possible to tell ILMerge to ignore the NodaTime PDB (without disabling merging of PDBs of other dependencies and generation of a PDB for the primary assembly)?

nuget package folder

Currently, the nuget package in \ILMerge.3.0.29\tools*net452*

Some dependent MSBuild.ILMerge.Task look for the executable in ILMerge.3.0.29\tools
hence fail to find the ILMerge.exe.

Since there is only one version, can you deploy in the \tools folder directly ?

Unresolved assembly reference not allowed: Embedded DLLs

Hi,

we have a compiled exe with embedded DLLs (AppDomain.CurrentDomain.AssemblyResolve loads them from the resources) as we need an exe without any additional files in production.

This program almost never gets recompiled, so I google'd and found ILMerge to just change the version (build number) of the exe to match with the product release without compile.

Unfortunately above error shows up because it can't find the dependencies.

WHY do you need to find all dependencies if I just want to change the version number (using /ver:) ?

Can this be changed?

On-Board project to the .NET Foundation

We're getting ready to bring the project into the .NET Foundation, but before we
do we need to do the following:

Getting into the .NET Foundation

  • Make sure the project has a good name that is easy to remember and
    spell. Check that it doesn't conflict with another existing project
  • Make sure the people involved in the project want to join the .NET Foundation
  • Make sure the project has a clear understanding about how it accepts contributions and the process
    it follows when selecting new committers to the project.
  • Register an interest in joining the .NET Foundation
  • Work with the .NET Foundation to fill out an On-Boarding Questionaire
  • .NET Foundation sends out completed questionaire to .NET Foundation Advisory Council for comments
  • .NET Foundation Executive Director submits new project proposal to the .NET Foundation Board
  • Configure a CI build for the project and ensure build status badges are available from the README

Once accepted into the .NET Foundation

  • Sign the contribution / assignment agreement
  • Agree a date to move into the .NET Foundation
  • Prepare a guest blog post announcing the move on the .NET Foundation Blog
  • Read the code of conduct,
    link to it in your code and
    understand what to do if you are concerned about any behaviour or have
    concerns reported to you.
  • Tell the world we have joined!
  • Get CLA Automation enabled to ensure contributors can easily sign the
    Contribution License Agreement
  • Send a PR to add the Project into the .NET Foundation
    list
  • Ensure the repo contents are up to date with .NET Foundation guidance
  • Review the README guidance and update if necessary
  • If applicable update the LICENSE file to show Copyright has been assigned to the .NET Foundation
    and look to update any file headers.
  • If applicable, update any copyright statements in websites owned by the project to reflect
    assignment to the .NET Foundation
  • If applicable, update any websites associated with the project to include
    "Supported by the .NET Foundation" or
    similar link back to the .NET Foundation in the footer. If applicable, please
    include image links from our swag repo. (We think a link in the footer using the horizontal logo looks very nice.)
  • Sign up for Project Leader news
  • Configure any resources requested from the .NET Foundation (SSL Certs, Code Signing,
    Secret Management, Build Servers etc)

how to merge my program and dlls with relative directory path

i have a winform project release like this:
a.exe b.dll c.dll en-US/d.dll

i use ./ILMerge.exe /targetplatform:v4 /ndebug /target:winexe /out:sa.exe a.exe b.dll c.dll en-US/d.dll
but when i run sa.exe, it says d.dll cannot be loaded.
i am new to ILMerge, is there anyone who can help me? thanks

AllowPartiallyTrustedCallers attribute missed after merge

Assemblies initialiy compiled with [assembly: AllowPartiallyTrustedCallers] lost this attribute after merge.
Steps to reproduce:

  1. Create new class library project (targetFramework: 3.5)
  2. Add line "[assembly: AllowPartiallyTrustedCallers]" to AssembliInfo.cs
  3. Call ILMerge by "Ilmerge /out:out.dll ClassLibrary1.dll /targetplatform:v2" command
  4. open out.dll in ILSpy or Reflector or any other tool
    Observed: there is no 'AllowPartiallyTrustedCallers' assembly attribute
    Expected: AllowPartiallyTrustedCallers attribute should be specified for the assembly (like in original ClassLibrary1.dll).

supportedRuntime arguments lost in merging

Hello,
I have a project which targets .NET 3.5, but should run successfully on an environment where only .NET 4.0 is installed. Here is my app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" />
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

As per Microsoft's documentation.

I run ILMerge with the targetPlatform flag:

/targetplatform:v2,C:/Windows/Microsoft.NET/Framework64/v2.0.50727

However, this path doesn't exist on a system without .NET3.5. When I run the merged exe, it fails, with a window notifying on a failure to install .NET3.5.
However, when I copy the entire built folder of DLLs and the original EXE and run it, it succeeds. The original EXE is compiled to .NET3.5, and runs successfully on a machine without .NET 4.0 as well.

I was looking for a way to use .NET's supportedRuntime configuration in the merged EXE, but I can't find one. Is there a workaround? Or is it just a missing feature?

Support for /TargetPlatform:v3.5 in ILMerge

Hello
Is there any support for .NET Framework 3.5 as Target Platform? I'm trying to make my app available on Windows 7 (Which has .NET 3.5 preinstalled).

This is my Post-Build event:

"%programfiles(x86)%\microsoft\ilmerge\ILmerge.exe" /out:"$(TargetDir)Merged\MyAppInstaller.exe" "$(TargetPath)" "$(TargetDir)AeroWizard.dll" "$(TargetDir)DotNetZip.dll" /targetplatform:v3.5

Here is the output:

1>  MyAppInstaller -> C:\Projects\MyApp\Deployment\MyAppInstaller\bin\Debug\MyAppInstaller.exe
1>  An exception occurred during merging:
1>  Platform 'v3.5' not recognized.
1>     at ILMerging.ILMerge.SetTargetPlatform(String platform, String dir)
1>     at ILMerging.ILMerge.Merge()
1>     at ILMerging.ILMerge.Main(String[] args)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(5019,5): error MSB3073: The command ""%programfiles(x86)%\microsoft\ilmerge\ILmerge.exe" /out:"C:\Projects\MyApp\Deployment\MyAppInstaller\bin\Debug\Merged\MyAppInstaller.exe" "C:\Projects\MyApp\Deployment\MyAppInstaller\bin\Debug\MyAppInstaller.exe" "C:\Projects\MyApp\Deployment\MyAppInstaller\bin\Debug\AeroWizard.dll" "C:\Projects\MyApp\Deployment\MyAppInstaller\bin\Debug\DotNetZip.dll" /targetplatform:v3.5" exited with code 1.

Thank you.

Problem with .Net Core assemblies

Hello,

I tried to merge several .Net Core assemblies together. Whereas this work fine for Microsoft assemblies like
for example System.Collections.dll, it fails for my own .Net Core assemblies:

ilmerge /log:ilmerge.log /out:CMD.exe CLI.exe Tethys.Logging.dll

Error message:

Trying to read assembly from the file 'D:\Software\SWC\sw360clients\SW360CLI_C#\SW360CLI\bin\Release\Tethys.Logging.dll'.
	Successfully read in assembly.
	There were errors reported in Tethys.Logging's metadata.
	Die Arraydimensionen haben den unterstützten Bereich überschritten.
An exception occurred during merging:
ILMerge.Merge: 	There were errors reported in Tethys.Logging's metadata.
	Die Arraydimensionen haben den unterstützten Bereich überschritten.
   bei ILMerging.ILMerge.Merge()
   bei ILMerging.ILMerge.Main(String[] args)

German 'Die Arraydimensionen haben den unterstützten Bereich überschritten.' stands for
...the array dimensions have exceeded the supported range ...

Tethys.Logging, version 1.4.2, is available on NuGet: https://www.nuget.org/packages/Tethys.Logging/1.4.2

Any ideas?

Thanks,

Thomas

process is terminated due to stackoverflowexception

I am using windows 7 and ILMerge is installed in "C:\Program Files\Microsoft".
When I am trying to merge four Dll files into single one, it is throwing "process is terminated due to stackoverflowexception" exception. Below command is used:
"ilmerge /out:Merged.dll Number1.dll Microsoft.SharePoint.Client.dll Microsoft.SharePoint.Client.Runtime.dll Microsoft.Xrm.Sdk.Deployment.dll"

Any suggestion/workaround would be helpful.

Thanks

Invalid IL after merge > InvalidProgramException at runtime

I ran into a case where ilmerge corrupts the IL code during merge. An example would be the Microsoft.CodeAnalysis.dll assembly. The method Microsoft.CodeAnalysis.SyntaxToken.GetFirstToken, among others, is missing an IL statement after the merge.

IL code before the merge:

  .method public hidebysig instance valuetype Microsoft.CodeAnalysis.SyntaxToken 
          GetFirstToken([opt] bool includeZeroWidth,
                        [opt] bool includeSkipped,
                        [opt] bool includeDirectives,
                        [opt] bool includeDocumentationComments) cil managed
  {
    .param [1] = bool(false)
    .param [2] = bool(false)
    .param [3] = bool(false)
    .param [4] = bool(false)
    // Code size       18 (0x12)
    .maxstack  8
    IL_0000:  ldsfld     class Microsoft.CodeAnalysis.SyntaxNavigator Microsoft.CodeAnalysis.SyntaxNavigator::Instance
    IL_0005:  ldarga.s   0
    IL_0007:  ldarg.1
    IL_0008:  ldarg.2
    IL_0009:  ldarg.3
    IL_000a:  ldarg.s    includeDocumentationComments
    IL_000c:  callvirt   instance valuetype Microsoft.CodeAnalysis.SyntaxToken Microsoft.CodeAnalysis.SyntaxNavigator::GetFirstToken(class Microsoft.CodeAnalysis.SyntaxNode&, bool, bool, bool, bool)
    IL_0011:  ret
  } // end of method SyntaxNode::GetFirstToken

And the code after the merge:

  .method public hidebysig instance valuetype Microsoft.CodeAnalysis.SyntaxToken 
          GetFirstToken([opt] bool includeZeroWidth,
                        [opt] bool includeSkipped,
                        [opt] bool includeDirectives,
                        [opt] bool includeDocumentationComments) cil managed
  {
    .param [1] = bool(false)
    .param [2] = bool(false)
    .param [3] = bool(false)
    .param [4] = bool(false)
    // Code size       16 (0x10)
    .maxstack  8
    IL_0000:  ldsfld     class Microsoft.CodeAnalysis.SyntaxNavigator Microsoft.CodeAnalysis.SyntaxNavigator::Instance
    IL_0005:  ldarg.1
    IL_0006:  ldarg.2
    IL_0007:  ldarg.3
    IL_0008:  ldarg.s    includeDocumentationComments
    IL_000a:  callvirt   instance valuetype Microsoft.CodeAnalysis.SyntaxToken Microsoft.CodeAnalysis.SyntaxNavigator::GetFirstToken(class Microsoft.CodeAnalysis.SyntaxNode&, bool, bool, bool, bool)
    IL_000f:  ret
  } // end of method SyntaxNode::GetFirstToken

Notice the missing "IL_0005: ldarga.s 0".

Windows 10

hi,
the latest dot net 4.7 is not support

IlMerge.exe process does not exit

I'm trying to merge 2 .net framework 4.5.2 dll, with:

ILMerge.exe /lib:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2" /ndebug /log:"C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.Merged.log" /target:library /out:"C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.Merged.dll" "C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.dll" "C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Utils.dll"

using ILMerge.exe.config:
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/> </startup> </configuration>

the ilmerge.exe process remain running indefinitely without return...

Here is the log:

ILMerge version 2.12.803.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /lib:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2 /ndebug /log:C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.Merged.log /target:library /out:C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.Merged.dll C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.dll C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Utils.dll
Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319..\v2.0.50727' for mscorlib.dll
Running on Microsoft (R) .NET Framework v4.0.30319
mscorlib.dll version = 4.0.0.0
The list of input assemblies is:
C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.dll
C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Utils.dll
Trying to read assembly from the file 'C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.dll'.
Successfully read in assembly.
There were no errors reported in DPGDocumentsHub.Api's metadata.
Trying to read assembly from the file 'C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Utils.dll'.
Successfully read in assembly.
There were no errors reported in DPGDocumentsHub.Utils's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
DPGDocumentsHub.Api.PeKind = ILonly
DPGDocumentsHub.Utils.PeKind = ILonly
All input assemblies have a compatible PeKind value.
AssemblyResolver: Assembly 'DPGDocumentsHub.Api' is referencing assembly 'RestSharp'.
AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'RestSharp' to 'C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\RestSharp.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Utils' is referencing assembly 'System.Drawing'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Drawing' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Drawing.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Utils' is referencing assembly 'System.Data'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Data' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Data.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'System.Data' is referencing assembly 'System'.
AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'System' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'System.Data' is referencing assembly 'System.Xml'.
AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'System.Xml' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Xml.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Api' is referencing assembly 'System.Core'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Core' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Core.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Api' is referencing assembly 'Newtonsoft.Json'.
AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'Newtonsoft.Json' to 'C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\Newtonsoft.Json.dll'. (Used referencing Module's directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Utils' is referencing assembly 'System.Web'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Web' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Web.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Utils' is referencing assembly 'Kendo.Mvc'.
AssemblyResolver: Attempting referencing assembly's directory.
Resolved assembly reference 'Kendo.Mvc' to 'C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\Kendo.Mvc.dll'. (Used referencing Module's directory.)
Using assembly 'DPGDocumentsHub.Api' for assembly-level attributes for the target assembly.
Merging assembly 'DPGDocumentsHub.Api' into target assembly.
Merging assembly 'DPGDocumentsHub.Utils' into target assembly.
Duplicate type name: modifying name of the type '�' (from assembly 'DPGDocumentsHub.Utils') to 'DPGDocumentsHub.Utils23664.�'
Duplicate type name: modifying name of the type '�' (from assembly 'DPGDocumentsHub.Utils') to 'DPGDocumentsHub.Utils23664.�'
Duplicate type name: modifying name of the type '�' (from assembly 'DPGDocumentsHub.Utils') to 'DPGDocumentsHub.Utils23664.�'
Duplicate type name: modifying name of the type '�' (from assembly 'DPGDocumentsHub.Utils') to 'DPGDocumentsHub.Utils23664.�'
Copying 1 Win32 Resources from assembly 'DPGDocumentsHub.Api' into target assembly.
There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'C:\DPGDocumentsHub\DPGDocumentsHub.Web\bin\DPGDocumentsHub.Api.Merged.dll'.
AssemblyResolver: Assembly 'DPGDocumentsHub.Api' is referencing assembly 'Microsoft.CSharp'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'Microsoft.CSharp' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Microsoft.CSharp.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Api' is referencing assembly 'System.Web.Extensions'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Web.Extensions' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Web.Extensions.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'Newtonsoft.Json' is referencing assembly 'System.Numerics'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Numerics' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Numerics.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'Newtonsoft.Json' is referencing assembly 'System.Xml.Linq'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Xml.Linq' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Xml.Linq.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Utils' is referencing assembly 'System.Configuration'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Configuration' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Configuration.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Utils' is referencing assembly 'System.Data.DataSetExtensions'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Data.DataSetExtensions' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Data.DataSetExtensions.dll'. (Used a client-supplied directory.)
AssemblyResolver: Assembly 'DPGDocumentsHub.Utils' is referencing assembly 'System.Management'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
Resolved assembly reference 'System.Management' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Management.dll'. (Used a client-supplied directory.)

Object reference exception

An exception occurred during merging: Object reference not set to an instance of an object. at System.Compiler.Ir2md.GetModuleRefIndex(Module module) at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type) at System.Compiler.Ir2md.GetTypeSpecIndex(TypeNode type) at System.Compiler.Ir2md.VisitReferencedType(TypeNode type) at System.Compiler.Ir2md.VisitStruct(Struct Struct) at System.Compiler.Ir2md.VisitModule(Module module) at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation) at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer) at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName) at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module) at ILMerging.ILMerge.Merge() at ILMerging.ILMerge.Main(String[] args)
This is the first time I have tried merging at /ver:4.5 with a specific /lib:C:\Windows\Microsoft.NET\Framework64\v4.0.30319, but did not expect this.

Windows 10, VS 2017 15.5.6. /log is turned on, too.

What else might help track this down?

Problem with generic types

Hello, I'm receiving the error at the end of the following log, with some generic types. I was able to reproduce the problem in the attached solution (please check README.txt). Thanks in advance.

ILMergeTest.zip

ILMerge version 2.14.1208.65535
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /log:D:\Temp\ILMergeTest\ILMergeTest\merge.log /targetplatform:v4 /out:D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTest.Merged.exe D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTest.exe D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTestLib.dll
Set platform to 'v4', using directory 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319..\v4.0.30319' for mscorlib.dll
Running on Microsoft (R) .NET Framework v4.0.30319
mscorlib.dll version = 4.0.0.0
The list of input assemblies is:
D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTest.exe
D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTestLib.dll
Trying to read assembly from the file 'D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTest.exe'.
Successfully read in assembly.
There were no errors reported in ILMergeTest's metadata.
Trying to read assembly from the file 'D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTestLib.dll'.
Successfully read in assembly.
There were no errors reported in ILMergeTestLib's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
ILMergeTest.PeKind = ILonly
ILMergeTestLib.PeKind = ILonly
All input assemblies have a compatible PeKind value.
Using assembly 'ILMergeTest' for assembly-level attributes for the target assembly.
Merging assembly 'ILMergeTest' into target assembly.
Merging assembly 'ILMergeTestLib' into target assembly.
Copying 2 Win32 Resources from assembly 'ILMergeTest' into target assembly.
Transferring entry point 'ILMergeTest.Program.Main(System.String[])' from assembly 'ILMergeTest' to assembly 'ILMergeTest.Merged'.
There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'D:\Temp\ILMergeTest\ILMergeTest\ILMergeTest\bin\Debug\ILMergeTest.Merged.exe'.
An exception occurred during merging:
Unable to cast object of type 'System.Compiler.Interface' to type 'System.Compiler.Class'.
at System.Compiler.StandardVisitor.VisitTypeParameter(TypeNode typeParameter)
at System.Compiler.StandardVisitor.VisitTypeParameterList(TypeNodeList typeParameters)
at System.Compiler.Specializer.VisitMethod(Method method)
at System.Compiler.StandardVisitor.VisitMemberList(MemberList members)
at System.Compiler.Specializer.ProvideTypeMembers(TypeNode typeNode, Object handle)
at System.Compiler.TypeNode.get_Members()
at System.Compiler.Specializer.GetCorrespondingMember(Member member, TypeNode specializedType)
at System.Compiler.Duplicator.VisitMemberReference(Member member)
at System.Compiler.Duplicator.VisitMemberBinding(MemberBinding memberBinding)
at System.Compiler.Duplicator.Visit(Node node)
at System.Compiler.Duplicator.VisitExpression(Expression expression)
at System.Compiler.StandardVisitor.VisitMethodCall(MethodCall call)
at System.Compiler.Duplicator.Visit(Node node)
at System.Compiler.Duplicator.VisitExpression(Expression expression)
at System.Compiler.StandardVisitor.VisitExpressionStatement(ExpressionStatement statement)
at System.Compiler.Duplicator.Visit(Node node)
at System.Compiler.StandardVisitor.VisitStatementList(StatementList statements)
at System.Compiler.StandardVisitor.VisitBlock(Block block)
at System.Compiler.Duplicator.Visit(Node node)
at System.Compiler.StandardVisitor.VisitStatementList(StatementList statements)
at System.Compiler.StandardVisitor.VisitBlock(Block block)
at System.Compiler.Duplicator.ProvideMethodBody(Method dup, Object handle, Boolean asInstructionList)
at System.Compiler.Method.get_Body()
at System.Compiler.Ir2md.VisitMethod(Method method)
at System.Compiler.Ir2md.VisitClass(Class Class)
at System.Compiler.Ir2md.VisitModule(Module module)
at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)

Description of cause of error ILMerge.Merge: The assembly 'Foo' was not merged in correctly. It is still listed as an external reference in the target assembly.

I recently ran into the error "ILMerge.Merge: The assembly 'Foo' was not merged in correctly. It is still listed as an external reference in the target assembly." There are a few references to this on the web but none I found helpful. Anyway after some debugging fun I found the following to be the cause, at least in my case.
Imagine you have three assemblies with the folowing dependencies

A -> B -> C
A -> C

You then try to ILMerge just assemblies A and C to produce a merged assembly AC. ILMerge will find the reference of C in B and regard it as an external reference to an assembly for the merged AC. However C is one of the assemblies which you are trying to ILMerge so at the end of the merge process it produces the message
"ILMerge.Merge: The assembly 'C' was not merged in correctly. It is still listed as an external reference in the target assembly."

This makes a lot of sense you can't both merge and not merge assembly C. The problem is that the error is not very clear. My general feeling is that
in a assembly dependency DAG if you try to merge two assemblies you must merge all intermediate assemblies between them. In the above eample the means assembly B.
Ideally there would be an initial step in ILMerge which constructed the DAG and complained in some obvious way.

At a minimum it would be good to mention assembly B in th error so
"ILMerge.Merge: The assembly 'C' was not merged in correctly. It an external reference in assembly B which is not being merged and is referenced by assembly A which is". I looked at changing the code to do this but don't understand it well enough at least so far.

Note this explains why the suggestion here
https://stackoverflow.com/questions/1807652/ilmerge-dll-assembly-not-merged-in-correctly-still-listed-as-an-external-refer to use /closed worked, adding /closed
implicitly adds assembly B to the assemblies you are trying to merge.

new nuget release?

The latest version of ilmerge on nuget.org is 2.14.1208. When will the 2.15 come out?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.