Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Ahead of Time Compilation

Does .NET natively support Ahead of Time Compilation? I see that Mono has done this to avoid JITing issues on other platforms (IPhone for example), and was wondering if its possible to build dll's to native code and run those in IIS. For dev, I would really like to be able to flip a switch on VS and IIS, so I only have to wait once for compilation instead of compile wait, JIT wait.

like image 989
Trent Avatar asked Sep 10 '25 06:09

Trent


2 Answers

Web Deployment Projects can run the aforementioned precompiler (aspnet_compiler.exe) as part of a build.

The precompiler takes care of parsing the .aspx, .ascx, .master files and compiling the parser generated code into assemblies. These assemblies still need JITed when the site executes. Theoretically this is where NGen could be useful, but I've never used it for server side code (a rule of thumb says that JITing is better for long running apps).

I have an old article on the aspnet_compiler here.

like image 107
OdeToCode Avatar answered Sep 12 '25 20:09

OdeToCode


You can pre-compile to IL, but not native code; NGEN isn't compatible with web sites, due to the way they are loaded into IIS.

In addition to Web Deployment Projects, which will let you merge your entire site into a single DLL, you can also use a "web application" project, which uses client-side compilation, instead of a "web site" project, which does server-side compilation.

like image 21
RickNZ Avatar answered Sep 12 '25 20:09

RickNZ