tags:

views:

380

answers:

3

This is what my .csproj AfterBuild looks like:

  <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
    <Exec Command="&quot;..\Tools\ILMerge\ILMerge.exe&quot; /internalize /ndebug /out:@(MainAssembly) /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 &quot;@(IntermediateAssembly)&quot; @(ReferenceCopyLocalPaths->'&quot;%(FullPath)&quot;', ' ')" Condition=" '$(TargetFrameworkVersion)' == 'v4.0'" />
  </Target>

I'm running 64-bit Windows. I have tried changing the .NET Framework from ...\Microsoft.NET\Framework\... to ...\Microsoft.NET\Framework64\... but it didn't help.

I also created ILMerge.exe.config in the ILMerge directory:

<?xml version ="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
    </startup>
</configuration>

Why isn't ILMerge generating a 4.0.30319 assembly?

+1  A: 

The same problem Here!!

I'm using ILMerge to target v4 with and without the /targetplatform:v4 and got the same result :.net runtime version targeting has greater .net v4 revision (as stated by reflector).

The base problem that took me to start digging was an error related to (Cannot load type System.Func´2 Exception from ) in a Linq and Lambda based code.

If I substitute the merged version with the non-merged version of the dependency assemblies no exception is thrown.

gonzalo.vinas
This is how I first noticed the problem, as well.
Sam Pearson
A: 

same problem with me.

Benny
If you have the same problem, express it by adding a comment to the question. In SO, Replies = Answers.
NLV
A: 

Hi, I have fixed ILMerge.exe (v2.10.0526) so that it sets the target runtime version v4.0.30319 and not v4.0.20926. You can download the fixed version of ILMerge.exe from this link:

ILMerge-v2.10.0526-fixed.zip

Just run it with this parameter as usual

/targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319

and the output assembly will now target v4.0.30319. I have checked with Reflector and it's ok. Let me know your results.

Note that you don't need to use that ILMerge.exe.config, I guess it's for running ILMerge.exe itself with the .Net 4 framework, however this doesn't mean it will force ILMerge.exe to produce .Net 4 assemblies. Target framework version of the output assembly is only controlled with the /targetplatform parameter.

tester
Hi tester, thank you! I'll try this out when I get the chance.
Sam Pearson