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 开发者_Go百科compile wait, JIT wait.
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.
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.
About the nearest you might get to that is using the ASP.NET compilation tool. You could also look at NGEN.
look at the -u option:
-u
from http://msdn.microsoft.com/en-us/library/ms229863%28VS.80%29.aspx :
"Specifies that Aspnet_compiler.exe should create a precompiled application that allows subsequent updates of contents such as .aspx pages.
If this option is omitted, the resulting application contains only compiled files and cannot be updated on the deployment server. You can update the application only by changing the source markup files and recompiling."
note that using ngen builds a native code version of the application for a specific version of the framework for a given machine instruction set (the one the application is running on). Installing a new version of the framework or changing the hardware means that you need to regenerate the native version.
精彩评论