I ran across a situation that causes aspnet_merge to fail when precompiling a website with a web deployment project in Visual Studio 2008. I could not reproduce the bug in Visual Studio 2005. I am using Visual Studio Team Systems 2008 Development Edition Version 9.0.21022.8 RTM and Microsoft Web Deployment Projects 2008 Version 9.0.21022. The web deployment project is configured to merge everything into a single output assembly.
Here is the console output when building the web deployment project
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\aspnet_merge.exe .\TempBuildDir -o WebAppOutput -a -debug -copyattrs
The "AspNetMerge" task is using "aspnet_merge.exe" from "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\aspnet_merge.exe".
Utility to merge precompiled ASP.NET assemblies. Version 3.5.21022.
Copyright (c) Microsoft Corporation 2007. All rights reserved.
aspnet_merge : error 1022: An error occurred when merging assemblies, possibly due to circular dependencies between two assemblies. The error reported is: ILMerge.Merge: The assembly 'App_Web_harmf_hl' was not merged in correctly. It is still listed as an external reference in the target assembly.
The command exited with code 1.
Opening up the output assembly (WebAppOutput) in Reflector shows it still has a reference to the assembly that holds the code behind class (App_Web_harmf_hl).
The workaround I found for this is to change the configuration of the web deployment project from a single output assembly to a seperate assembly for each page and control.
To reproduce, place this code in a class library
using System;
using System.Collections.Generic;
using System.Text;
namespace GenericsLib
{
public abstract class AbstractGeneric<T> where T : AbstractGeneric<T>, new()
{
}
}
Create a file system based web site with a single page. Add a reference from the web site to the GenericsLib project. Open the code behind for the page and put the following code in the page class
private void DoSomething<T>() where T : GenericsLib.AbstractGeneric<T>, new()
{
}
Add a web deployment project for the web site, and configure it to merge all the output into a single assembly. Build the web deployment project and an ILMerge error should happen. Again, this only happens in the Visual Studio .Net 2008 version of aspnet_merge and not in the version that shipped with Visual Studio 2005.
Thanks,
James H.