Search code examples
asp.netcompilationpublishprecompiledpre-compilation

Is the Publish option in Visual Studio considered pre-compilation for ASP.net Web applications?


I'm having trouble understanding when the site is considered "pre-compiled". As I understand what I've read, if I use the Publish or Build Deployment Package options from within Visual Studio then it is pre-compiling, but if I just use something like xcopy, then it is not pre-compiled. Is that correct?


Solution

  • ASP.NET WebSite projects have an option of xcopy deployment in which all files including the aspx, aspx.cs, ascx, ascx.cs etc are copied to the production web server as is. The ASP.NET runtime compiles the site when it receives the first request. If you check the folder C:\Windows\Microsoft.NET\Framework\v\Temporary ASP.NET Files, you could see the output. This obviously is very easy for deployment as all we have to do is to copy the files over to the web server. However, the first visitor pays the price in terms of when the site gets compiled for the first time. The publish option does this work before the deployment. It compiles the website project and produces assemblies that are ready to run. There is an option in the publish to leave the aspx files as is so that those can be modified. In both cases there are no .cs files as those have been compiled to the assemblies. Check Walkthrough: Publishing a Web Site for more details.

    HTH