Monday, March 04, 2013

StyleCop and ILMerge don't mix

Just in case anyone else has the same sort of bright idea that had me flummoxed for a while today...

I had put together a little tool for some C# meta-programming that mixed some reflection with some source code parsing driven through the StyleCop parser, and it was working nicely, but actually deploying it was a nuisance, because it wanted the StyleCop assemblies as well as just the .exe -- so I thought to myself "Let's ILMerge it all together, that should be nice and convenient."

And that's when the test harness stopped working, with no parsers found.

Chasing through the decompiled sources, it appears that the parser assembly StyleCop.CSharp.dll gets loaded by looking through other co-located assemblies with the same strong-naming key and whose name ends in ".dll" -- assumptions which merging into a .exe for distribution had just blown away.

Apart from having to manage what is no longer a single unit, however, the end result of using StyleCop for examining source (and in particular comments and suchlike not compiled into the assembly being reflected upon) in conjunction with reflection worked very nicely.


Post a Comment