I have an ASP.NET 4.0 web application which needs to be pre-compiled into a single Assembly. I have played around with the available options and I am getting following:
1. When I compile I get a separate assembly for each page as following:



The easiest way to do this is to Create (or change) your project as (or to) an "Asp.Net Web Application" rather than the "Asp.Net Web Site".
This will cause your project to be compiled into a single dll, rather than the "dll per page" or "dll per directory" scheme that the web sites normally work off of. It will also force you to resolve any type name problems (IE: if you have 6 pages called Default), It's important when you make a single assembly that fully qualified names be unique.
This will give you a proper project file (build script) and dump all your dll's out to the /bin folder when you compile.
You can then use something like ILMerge to combine all your assemblies in the /bin folder into a single dll if that's what you want to do. This assumes all your references are managed assemblies, if you have any non .Net libs it's going to be a lot trickier, although still not impossible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With