Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET pre-compile into a single assembly

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: Multiple assemblies

  1. When I compile I get a single assembly of the web application but on the live server every page is dynamically compiled and a temp file is generated.

Dynamic compiling

  1. I need a way to compile my web application into a single assembly which allows UI updates (HTML changes not the code) and does not generate temporary files.

enter image description here

like image 649
Usman Akram Avatar asked Jan 28 '26 00:01

Usman Akram


1 Answers

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.

like image 62
Brook Avatar answered Jan 30 '26 12:01

Brook



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!