New version of ASP.NET Merge Tool
The ASP.NET Merge tool (Aspnet_merge.exe) enables you to combine and manage the assemblies that are created by the ASP.NET compilation tool (Aspnet_compiler.exe). It was built on top of a Microsoft Research project, ILMerge, through which Aspnet_merge.exe does IL code merge.
What problem does this new version fix?
The first version of this tool was released through .Net framework 2.0 SDK, since then we haven’t update the ILMerge part much. As .Net evolved, IL becomes more and more complex and the old ILMerge can’t work correctly in some corner cases. This leads to a CLR failure to load the resulting merged dlls. In this release, we took the latest version of ILMerge into Aspnet_merge which fixes those issues.
How to use the new version of the ASP.NET Merge tool?
1. Manage NuGet packages in your project and search for Microsoft.Aspnet.Merge. Please check the Include prerelease box, because this is a beta release.
2. Right click on your web application project and click on Publish (or Publish Web Site in web site project) to create a publish file for your project.
3. Click File Publish Options in Settings, you should see precompile option. Then click on Configure and you will find several merge options. You can select one of them based on your requirement. Below are the explanations of each option.
- Do not merge – just use aspnet_compiler.exe to precompile the whole web application without merging assemblies.
- Do not merge. Create a separate assembly for each page and control – This uses the -fixednames option on aspnet_compiler.exe. It does not merge the assemblies, but creates a separate one with a consistent name (based on the path) for each file.
- Merge all outputs to a single assembly – This is the same as the -o option on aspnet_merge. It will precompile your site and put it all entirely in one assembly.
- Merge each individual folder to its own assembly – This is the same as the -prefix option on aspnet_merge. It will precompile each directory separately into <prefix>.<directoryName>.dll.
- Merge all pages and control outputs to a single assembly – This is the same as the -w option on aspnet_merge.exe. It will compile all of the UI pages (.aspx, .ascx, .master, etc…) into a single assembly.
If you find any issue or want to ask a question regarding what’s discussed in this article, please leave a comment below, or use the Contact Owners Form on the NuGet package details.