views:

42

answers:

1

Hi,

Totally stupid question, but I'm writing my first ASP.NET C# web forms application and sometimes I can just write a change and save it in Visual Studio and it works just dandy, but other times it seems I have to rebuild the project for changes to take effect.

Could anyone please tell me what conditions need to be met for me to rebuild?

Thanks!

Tom

+5  A: 

Any changes to compiled code will require a rebuild. This includes:

  • *.cs
  • *aspx.cs
  • *.designer.cs
  • Global.asax.cs

The gotcha here is the word "compiled". Even the *.aspx *.asmx files are compiled, but this is done Just-In-Time (JIT) before the page is executed. The compiled output is cached and reused, but the runtime will detect changes to a few files and re-JIT them.

An interesting side: changes to the root web.config of your site will force a rebuild.

There are few changes that won't require a recompile.

  • *.aspx unless you are adding/removing server controls/user controls or assembly references
  • *.aspc unless you are adding/removing server controls/user controls or assembly references
  • textual data files such as *.txt, *.xml unless you are accessing these files in a read-once and cache pattern.
  • other textual files JavaScript (.js) and Stylesheets (.css) (thanks jerone)

TIP: If you have a large solution, with many projects, you don't have to re-compile every one of them each time you make a change. Just compile the projects that you have changed by right-clicking the project in Solution Explorer and clicking Build. If you have unsaved changes to files not in the selected project, these will not autosave and will be excluded from the build.

Daniel Dyson
Great answer, thank you very much Daniel!
Tom Gullen
textual data files that don't need a rebuild include JavaScript (.js) en Stylesheets (.css) too.
jerone