Monday, April 28, 2008

ILMerge redux

In my previous post, I mentioned a problem I was having with ILMerge and how I fixed it.

It turns out that code security attributes were not the only problem.  ILMerge is no longer complaining, but it is generating a bad output assembly just the same.  This is preventing the C# compiler from linking to the merged assembly.  Most immediately it manifested as XmlSerializers not working.

PEVerify shows a long stream of errors:

C:\Source\MbUnit\v3>"c:\Program Files\Microsoft.NET\SDK\v2.0 64bit\Bin\PEVerify.exe" build\target\bin\Gallio.dll

Microsoft (R) .NET Framework PE Verifier.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

[MD]: Error: TypeDef is marked Nested but has no enclosing type. [token:0x020004
[MD]: Warning: MemberRef has a duplicate,  token=0x0a0004f3. [token:0x0A0001AB]
[MD]: Warning: MemberRef has a duplicate, token=0x0a0004f4. [token:0x0A0001AC]



More Good Fortune?

I upgraded ILMerge from 2.8.0202 to 2.8.0422 and now it seems to be working a little better.

Now the TypeDef error is gone but we're still getting MemberRef warnings.  Makes me a bit nervous but at least the C# compiler is happy enough linking to the merged assembly and the XmlSerializer problem seems to be resolved.

However, there was nothing in the change history to suggest that any bug were fixed.

Or Maybe Not?

Turns out I missed these errors:

[IL]: Error: [C:\Source\MbUnit\v3\build\target\bin\Gallio.dll : Gallio.Model.Execution.ManagedTestCommand::get_Children][offset 0x00000012][found ref 'System.Collections.IEnumerable'][expected ref 'System.Collections.Generic.IList`1[Gallio.Model.Execution.ITestCommand]'] Unexpected type on the stack.
[IL]: Error: [C:\Source\MbUnit\v3\build\target\bin\Gallio.dll : Gallio.Model.Execution.ManagedTestCommand::get_Dependencies][offset 0x00000012][found ref 'System.Collections.IEnumerable'][expected ref 'System.Collections.Generic.IList`1[Gallio.Model.Execution.ITestCommand]'] Unexpected type on the stack.
2 Errors Verifying build\target\bin\Gallio.dll

Just great.  Well, I guess Gallio Alpha 3 will be delayed a little bit further while I cook up a workaround or something.

Technorati Tags:


Anonymous said...

Is there some kind of absolute requirement that Gallio Alpha 3 be ILMerged? If not, I'd say "release away!". If so, I'd say "why?"

Jeff Brown said...

ILMerge is used in Gallio to avoid having direct references on the Castle Windsor assemblies.

We internalize these references to avoid version conflicts when testing applications that use Castle Windsor themselves.

This was actually working fine until I did a little refactoring last night to eliminate a "redundant" assembly.