Saturday, June 6, 2009

Usage of aspnet_compiler.exe and aspnet_merge.exe

Whenever website or webapplication publish,aspnet_compiler.exe is used for compilation. 

Example :

WebSite : c:\myProject\TestSite

1 . Go to Visual Studio Tool from program menu and start Visual studio command prompt.
     If you do not have visual studio installed on your machine and just .NET Framework 2.0 installed on your machine then also you can use aspnet_compiler tool. 
- Start > run  and type cmd.
- set path=%windir%\Microsoft.NET\Framework\v2.0.50727
- aspnet_compiler –v / –p c:\myproject\testsite c:\testcompile
   It will compile c:\myproject\testsite and put published site in c:\testcompile. 
- When you compile site using above command site is not updatable after publish. 
-  If you want to site updatable after publish add –u option to it.
- It is good to add –f option in order to override existing published site.
- Fore more help just type aspnet_compiler /?

Now let discuss about aspnet_merge.exe tool. This tool is introduce later and it is used to merge all assemblies that is located in bin directory of published site. When you published website project many assemblies are in bin directories depending upon your option.

- In aspnet_compiler if you add –fixednames option then it will generate single assembles for each page otherwise it is generated per directory (this is default for website project).

- Main disadvantage of different assembles either way is problem with reflection. You are not able to get control and page information located in another assemblies without assemblies loading programmatically.

- aspnet_merge.exe tool merge all aspnet generated assemblies to single assemblies.

Example :

1. set path=%programfiles%\Microsoft SDKs\Windows\v6.0A\bin
2. aspnet_merge c:\testcompile
   This will create single DLL ( assembly ) in bin directory.
3. To set generated assembly name use this.
    aspnet_merge –o Single.dll c:\testcompile.

Hope this will help you.

Please give your comment and advice on this.


rg said...

very informative !

ShajiVK said...

really ! good. Simply expalined.