Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I precompile ASP.NET 2.0 sites before deployment or not?

Where I work, we do a very large number very small ASP.NET apps, and it has happened a few times that sites have been deployed in precompiled format, and the app needs to be changed, but the version of the code available in source control is out of date and the developer is not available. The app's dll has to be decompiled and hacked back together.

Ideally, it would never happen that a develpoer rushes a change through testing and production and skips checking in the change, we have since made changes to our policies to keep this from happening, but I wonder if the overhead of compiling a site on the server whenever the app pool restarts is a big enough problem that we should avoid uploading our code directly to the server. It would be easier to check the version in source control vs the actual live version if we could download the live source.

What are the advantages of precompiling VS uploading cs files directly to the server and having them compiled there?

like image 832
NetHawk Avatar asked Jun 15 '09 15:06

NetHawk


People also ask

What ASP NET deployment method is used to Precompile Web site content before installation?

You can precompile a Web site using the Aspnet_compiler.exe tool on the command line. For more information, see How to: Precompile ASP.NET Web Sites for Deployment and ASP.NET Compilation Tool (Aspnet_compiler.exe). Visual Studio also includes commands to precompile a Web site from the IDE.

Does ASPX need to be compiled?

aspx. cs file) must first be compiled. This compilation can happen explicitly or automatically. If the compilation happens explicitly then the entire application's source code is compiled into one or more assemblies ( .

What is Precompile during publishing?

Precompilation performs essentially the same compilation process that normally occurs when a page is compiled dynamically upon being requested in a browser. The precompiler produces assemblies from the pages, including both the markup and the code.


2 Answers

I disagree with most of the answers given to this point. There are many advantages to precompiling over ad-hoc posting of files, not the least of which is that the code in the production and testing environments stay more or less in sync. Pre-compiling makes it certain that the code you tested is the code going to production every time.

The issue you are running into is not one of pre-compile versus first-run compile. Instead it stems from the type of source control you are using. If I had to guess (and I do), I would say you are running Visual SourceSafe. If you were to switch to a source control system that made branching and merging trivial then you could separate your code into stable and development branches. Bug fixes happen against the dev branches (which then get merged back to the stable branch once validated). That way, untested or otherwise not-ready-for-prime-time code does not end up on the production server and you always have a copy of the stable set to work from.

like image 195
Rob Allen Avatar answered Nov 16 '22 02:11

Rob Allen


From purely an ease of use standpoint, I do like simply uploading the source files to the server and forget about pre-compiling.

This is what I do for all of the sites I manage, even the big ones. I do try to make a habit of hitting the more important pieces of the application to make sure everything works (and to compile them while I'm at it).

And here's another thought. If the site is public you can let the w3c link checker loose on it. This will have the effect of compiling every page it hits. And it's a nice thing to do anyway to ensure you don't have any broken links.

Simply put, I suppose these routine checks almost eliminate the problem of slow first-visit-compilation from your users. And since it's a good routine to follow anyway, it has worked out well for me.

like image 30
Steve Wortham Avatar answered Nov 16 '22 03:11

Steve Wortham