When attempting to merge several assemblies in a VS Post Build I ran into the issue:
ILMerge version 2.13.307.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /out:Assembly.dll AssemblyA.dll AssemblyB.dll /targetplatform:v2,C:\Windows\Microsoft.NET\Framework\v3.5 /log:log.txt
Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework\v3.5' for mscorlib.dll
An exception occurred during merging:
Unable to cast object of type 'System.Compiler.Class' to type 'System.Compiler.Struct'.
at System.Compiler.SystemTypes.Initialize(Boolean doNotLockFile, Boolean getDebugInfo, PostAssemblyLoadProcessor postAssemblyLoad)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
where AssemblyA is the current project output $(TargetFileName) and AssemblyB is a referenced assembly.
- AssemblyA => v3.5
- AssemblyB => v2.0
The weird thing is that when I change the command to use .NET 4 it works:
ILMerge /out:Assembly.dll AssemblyA.dll AssemblyB.dll /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 /log:log.txt
Since I wish the merged assembly to be version 3.5 and not 4 how do I get the former command to work or how do I resolve this error?