- ASP.NET Compilation
- Automating aspnet_compiler.exe in Visual Web Developer Express Edition
Automating aspnet_compiler.exe in Visual Web Developer Express Edition
As I pointed out previously, there is a menu option in Visual Studio 2008 that automates the use of the aspnet_compiler.exe so that you can easily precompile your applications. That menu option does not exist in Visual Web Developer Express Edition, but you can easily add it to the menu by configuring aspnet_compiler.exe as an external tool in Visual Web Developer Express Edition.
To configure menu options for precompiling your web application in Visual Web Developer Express Edition, follow these steps:
- Launch Visual Web Developer Express Edition.
- Select Tools, External Tools to access the External Tools dialog.
- Type Pre-&Compile (non-updatable) in the Title text box.
- Click the browse button next to the Command text box and browse to aspnet_compiler.exe in the Windows\Microsoft.NET\Framework\v2.0.50727 directory.
- Click Open to select the aspnet_compiler.exe application.
- Type -p " in the Arguments text box.
- Click the right-facing arrow button on the right edge of the Arguments text box and select Project Directory, as shown in Figure 3.3.
Figure 3.3 You configure the arguments for aspnet_compiler.exe by using the menu to the right of the Arguments text box.
- Enter a closing quote at the end of the arguments you've entered so far. At this point, the Arguments text box should contain the following text:
-p "$(ProjectDir)"
- Press the spacebar to add a space at the end of the arguments you've entered so far, and then type -v / ".
- Click the right-facing arrow button at the right edge of the Arguments text box again and select Project Directory.
- Type \..\CompiledApp" after the existing arguments. At this point, the Arguments text box should contain the following text:
-p "$(ProjectDir)" -v / "$(ProjectDir)\..\Compiled"
- Check the Close on Exit check box.
- Click OK to add the new external tool to the list.
You now have a new menu option in Visual Web Developer Express Edition (see Figure 3.4) that enables you to precompile your web application as a non-updatable application.
Figure 3.4 Adding a menu option in Visual Web Developer Express Edition to automate the aspnet_compiler.exe utility is simple and makes it much more convenient to precompile your applications.
Now let's add a second external tool that precompiles a website and makes it updatable.
- Select Tools, External Tools to access the External Tools dialog.
- Click Add to add a new external tool.
- Enter Pre-Co&mpile (updatable) in the Title text box.
- Configure all other settings as you did before, but this time, add the -u argument to the Arguments text box. The arguments text box should contain the following text:
-p "$(ProjectDir)" -v / "$(ProjectDir)\..\Compiled" -u
When you select one of the new menu items, your ASP.NET application is precompiled into a directory called Compiled. That directory is one level above your ASP.NET application. Therefore, if your ASP.NET application is located at c:\mysites\myWebApp, the precompiled website is saved to c:\mysites\Compiled.