简体   繁体   中英

ASP.NET when am I meant to build my project

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM