views:

427

answers:

5

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?

A: 

It would depend on the size of the applications and the frequency of use. If it's being used regularly enough that the app pool is only recycled at the end of the day, a brief wait on first launch in the morning may be worthwhile. If it's only getting hit once every 30 minutes, forcing a recompile each time, it may be worth precompiling.

Of course, if it's a very large app that takes a while to compile on first run, I'd lean towards precompiling, especially if it's not getting constant use.

orthod0ks
I have a number of ASP.net apps on the local intranet. All of them are deployed as source code. Some of them are rather infrequently used. But after the very first compile, they always seem to come up very quickly. Do you have any source for your information about a 30 minute cache timeout? My experience seems to indicate otherwise.
recursive
The application pool gets recycled after 20 minutes, so hitting it just after that means you get the startup/compile hit
Sander Rijken
The apps aren't very large, really just a few pages and assemblies. I've tried to access some on the server that weren't precompiled and just deployed. The time it takes to access those ones was noticeable (I was looking for it), but not that bad. Most of them also don't see a lot of access.
NetHawk
30 minutes was just an example. I don't know what the default cache timeout is off the top of my head. I have noticed in our environment, it seems to be in that ballpark though.
orthod0ks
A: 

The main advantage is in compiling performance on webserver. Also it protects your code, because it is harder to read the code from assembly :-)

Jan Remunda
Protects your code from whom? The customer?
Chad Ruppert
Actually, Ishtar, It is almost trivial to decompile a .NET assembly with Reflector. Since the webserver doesn't serve files that should be protected in ASP.NET, like .cs files and your web config, is that really a big advantage?I agree that performance is the most popular concern. Thanks for your answer.
NetHawk
Every programme can be decompiled.. But it's "harder" to read it. If you have published uncompiled projects, anyone can directly read a modify your code.
Jan Remunda
I am not sure that is either of those statements is entirely true.
NetHawk
+1  A: 

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.

Steve Wortham
Thanks, Steve. Is every page compiled separately? It seems like the performance hit is all on the first request.
NetHawk
The aspx files are compiled separately. In the typical configuration, the code-behinds are not since they're rolled into a DLL.
Steve Wortham
A: 

I upload files without precompiling: in this way, since my code is very buggy, i can correct it with Notepad++ directly from the server

Also, Visual Web Developer 2008 (the free one) does not have the compiling option :-P

Magnetic_dud
+4  A: 

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 stable branch (which then get merged back to the dev branches. 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.

Rob Allen
Thanks, Rob. I'm voting this up as a good counterpoint and defiantly useful. This does seem like good process, and our whole system here is really ad-hoc. You are correct that we use SS here, and I would love to use something better.
NetHawk