开发者

ASP.NET pre-compile into a single assembly

开发者 https://www.devze.com 2023-03-04 12:51 出处:网络
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:

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:

ASP.NET pre-compile into a single assembly

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

ASP.NET pre-compile into a single assembly

  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.

ASP.NET pre-compile into a single assembly


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.


The aspnet compiler is included with the framework. Here is a page describing how to use it. http://msdn.microsoft.com/en-us/library/ms227972.aspx

Here are some additional pages for reference:

  • http://msdn.microsoft.com/en-us/library/bb398860.aspx
  • http://msdn.microsoft.com/en-us/library/ms228015(v=vs.85).aspx


AFAIK you cannot update the UI/html without the server recompiling the page using temporary files

All .aspx, .ascx files etc. are transformed to source code and then compiled. The only method ASP.NET provides to prevent that is to compile the pages and controls as well, but then your site is no longer updatable. In that case you would always need to redeploy the binaries for every update.

Any specific reason why you don't want ASP.NET to generate temporary files? It's a perfectly acceptable practice I think.

0

精彩评论

暂无评论...
验证码 换一张
取 消