When you click Build Web Site, it doesnt compile all of the .cs files into a single dll. It only validates that the code is syntactically correct. It will validate the .cs files as well as the .aspx and .ascx files.
When you run it through the debugger or you use xcopy deployment directly against the files in your web project, it uses dynamic compilation to run the web site. This means that if you change a .cs file, the next time that file is hit in a web browser, it will compile it on the fly.
So when you want to deploy the web site, you click Publish Web Site. You can also do this using the new aspnet_compiler.exe and point it to a solution file.
The Publish Web Site dialog will prompt you for a location. This can be a file path, a web site address, or ftp site. It also has three different checkbok options:
- Allow this precompiled site to be updatable
- Use fixed naming and single page assemblies
- Enable strong naming on precompiled assemblies
1. Allow this precompiled site to be updatable
The Allow this precompiled site to be update option when checked leaves all of the .aspx and .ascx files alone. This way they can be changed by an external tool. When it is unchecked, it compiles the entire site including .aspx and .ascx files into a single dll or multiple dlls.
When you publish with this option, we get the following in bin folder under published folder.
- .compile file and the corresponding file should be placed for each update of a given aspx, master file and if there is only change is code-behind class, this file should be included too.
- For code change in App_Code, no need to copy App_Code.compiled, just copy App_Code.
- For code change in Global.asax, no need to copy App_global.asax.compiled, just copy App_global.asax.dll.
- For changes in CSS files of App_themes CSS should be copied manually.
2. Use fixed naming and single page assemblies
For deploying assemblies of a ASP.NET 2.0 projects there are three ways to do:
- Single page assembly
- Batch assembly
- Merged assembly
The filename format for a particular dll will be App_web_<filename>.<random four byte hex string>.dll. . So the filename for the default control would look like this, App_web_default.ascx.2ce8cdef.dll. The random four byte hex string is supposedly the same every time you compile. It also seems to use the same string at each directory level. When unchecked there is no guarantee what the filenames will be in the dlls and entire directories will be grouped into the same dlls.
Single page assembly
In Visual Studio 2005, for a ASP.NET 2.0 web application, we can deploy separate assemblies for each pages of the site! This can be done by enabling the above option.
If the 'Allow this precompiled site to be updatable' is disabled, that means a corresponding .compile file should also be deployed with the assembly of each page. In this case, if there is any change in the page, we need not to deploy the updated .compile file in the web, as all contents are placed in the dll, but as the resource locator or for the basic rule, Atlas one version of .compile file should be placed in the bin directory of the deployment site.
Any way, no matter, whether the change has been done in content or code, the page dll MUST be deployed! For a change in content, if only .compiled is provided, there is no error, but change will not take effect!
Batch assembly
For different type of contents and codes, different sets of assemblies will be generated, if we make the above option false. So any change in the code of a page, requires the corresponding set of assemblies to be deployed.
The Use fixed naming and single page assemblies option tells the compiler to use the same names for the dlls it creates every time it compiles. It also will make the compiler create seperate dlls for every page and control on the site. This will allow for indiviudal controls to be updated without affecting any of the other ones.
For batch assembly, each dll includes a encrypted key in it's name and for separate web publishing, there are separate keys for the same type of contents, thus separate file name for the newer version.
Merged assembly
All of the coding contents can be embeded to a single assembly, like VS 2003 age, using a VS add-in named 'aspnet_merge.exe' provided by Microsoft. Unfortunately, this tool is not provided by default and should be downloaded and installed separately.
3.Enable strong naming on precompiled assemblies
Enable Strong Naming on Precompiled Assemblies is basically the same as specifynig a key in the assemblyinfo.cs in ASP.NET 1.1.
Depends on the requirement and necessity we can choose any of the method given above.
Use the technology!!!