Merging ASP.NET 2.0 without aspnet_merge
Apparently Microsoft will be releasing a tool called aspnet_merge that will help resolve some of the shortcomings in the deployment options when precompiling ASP.NET 2.0 projects. This is supposed to be available on November 7th, but I don’t feel like I want to wait. Thanks to the DotNetNuke guys for working with Microsoft on this. I’m really surprised that it got to be so late in Microsoft’s development cycle before they figured out this was a problem.
I thought I’d try ILMerge to do it. Searching to see if someone else had, I came across this post by K. Scott Allen: Using MSBuild and ILMerge to Package User Controls For Reuse. Similar problem, different goal.
I went ahead and did this with nant as that was the quickest way for me to get this into my release process. I admit this is all a kind of a hack. First, I search for all App_Web*.dll files. Then I replace all references in the aspx and ascx files with a reference to my new merged dll. Finally, I use ILMerge to merge to the new dll. Note that I’m not merging everything, just the assemblies that have seemingly random names.
The nant code follows. It is a bit clumsy, but it works.