How to fix: error MSB6006: “aspnet_merge.exe” exited with code 1

less than 1 minute read

One of the most annoying Visual Studio errors are the ones that don’t give you any details of what is wrong. This is one of those errors:

error MSB6006: "aspnet_merge.exe" exited with code 1

To fix it open a command line at the root of your project and enter this command:

msbuild /verbosity:detailed > output.txt

Now open output.txt and search for “MSB6006”. You’ll probably see the error right above the error line. This is the error that I usually get:

An error occurred when merging assemblies: ILMerge.Merge: ERROR!!: Duplicate type '<ClassName>' found in assembly 'App_Web_b6it0-k1'.

Usually when I get this error it is because I copied some files to create new pages but forgot to rename the classes. This causes naming conflicts because there are multiple classes with the same name. Just search your code for and you will probably find it defined in multiple places.