ASPNET 2 Compilation Again

few ways of deploying a .NET 2.0 ASP.NET application.

- April 20, 2015

Rest of the Story:

There are a few ways of deploying a .NET 2.0 ASP.NET application

  • using Web Site Deployment Project
  • using VS.NET Publish Command
  • using VS.NET Build Command

1.) Using VS.NET Build
ASP.NET not Visual Studio performs the build.  ASP.NET builds everything, including .cs and .vb code files and places all resulting assemblies in folder structure under Temporary ASP.NET files directory.  As ASP.NET does all of the compilation, the debug setting in the compilation section of the web.config controls debug or release mode.  Compile with debug=true and you'll find the .pdb debugging symbol files alongside each assembly.  In this scenario the Configuration Manager is obsolete (not used) and as such the only option is 'Debug'.

2.) Using VS.NET Publish
This option is available when you are ready to publish to production.  The Publish command will precompile a web application and place the results into a director of your choosing (IIS/FTP/Directory).  Options are available on the Publish dialog box that map to aspnet_compiler switches.  The aspnet_compiler tool has option to create pdb files however this is not available on the dialog box (within  Publish always builds in release mode without pdb files.  The Publish command does not change the debug setting in the web.config SO if you precompile and updateable (option 'allow this precompiled site to be updateable') web site and then update the web site in place (which will result in a dynamic compilation) those dynamic compilations will produce debug code and pdb files.
3.) Using Web Site Deployment Project (WSD)
This project allows VS.NET to use MSBUILD files provided by WSD to ask for debug and release builds.  This tool uses the aspnet_compiler similar to above with the Publish option however the WSD option will change the debug setting in the web.config to false for release builds (different than the Publish option)  By default the built files will be in respective debug or release directories.

VS.NET Build - builds web site to Temporary ASP.NET files directory with options specified in web.config
VS.NET Publish - builds to release mode (always) however does not change the compilation mode in web.config file (which can lead to less than optimum performance if site is dynamically recompiled)
Web Deployment Project - Builds based on Configuration Manager mode (debug/release) AND updates the web.config with additional options for creating debug symbols and swapping out web.config sections based on release mode