I am trying to get a basic VS 2012 project working with ILMerge, so I can eventually move up to more complicated examples (and eventually be able to use it with my real project).
Currently I have a working project, TestMain
, and a reference library, TestDLL
in the working project.
My working directory (..\bin\Release) is as follows:
- ILMerge.exe
- TestDLL.dll
- TestDLL.pdb
- TestMain.exe
- TestMain.exe.config
- TestMain.pdb
- TestMain.vshost.exe
- TestMain.vshost.exe.config
- TestMain.vshost.exe.manifest
My terminal output is as follows:
C:...\bin\Release>ilmerge /target:winexe /out:ContainedProgram.exe "TestMain.exe" "TestDLL.dll"
An exception occurred during merging: ILMerge.Merge: Could not load assembly from the location 'C:...\bin\Release\TestMain.exe'. Skipping and processing rest of arguments. at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
Pretty simple, right? What am I missing here?
Update: Removing the .exe and running ILMerge with only the library works. Removing the .dll and running it with only the executable doesn't change the error output.
I also made a second .dll and was able to use ILMerge to merge the two existing libraries into one with the following:
ilmerge /targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319 /out:Test.dll "TestDLL2.dll" "TestDLL.dll"
Update 2 So I was able to create a TestRun.exe with the following:
ilmerge /targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319 /out:TestRun.exe "TestMain.exe" "Test.dll"
This took the two reference library .dll's packaged together and packaged them with my executable. And it worked! I was able to get the expected results.
Until I moved my new executable out of its home folder.
As soon as I moved it to a new location, execution produced this error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'TestDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at TestMain.Program.Main(String[] args)