Extreme ASP.NET Makeover: Getting Your House in Order - Inspecting a Proj File
- Posted: Jun 04, 2009 at 11:56PM
- 16,091 views
Right click “Save as…”
In creating a build script, we want to automate common tasks for building the project source code as much as possible. Whether you know it or not, you are already using build scripts. When you create a new project, Visual Studio creates a build script for that project in the form of a .csproj or .vbproj file. (MSBuild was introduced with .NET Framework 2.0, so project files created by Visual Studio 2005 and above use the new MSBuild format under the covers.) If you open a project file in a text editor such as Notepad rather than Visual Studio, you will see something like this clip.
To run a build from the command line, simply launch a Visual Studio 2008 Command Prompt, navigate to the solution root, and execute:
Running the Visual Studio 2008 Command Prompt instead of the standard command prompt ensures that the Visual Studio and the .NET Framework directories are added to the PATH environment variable, enabling you to execute commands like msbuild.exe without specifying the full path to the executable. In addition to compiling the entire solution, you can compile individual projects.
Rather than editing the project files directly, I will create a separate build file for building the solution from the command line. If you are creating a custom build file, the two most commonly used build engines on the .NET platform are MSBuild and NAnt. (Other options include rake, Bake, and psake, among others.) I will use MSBuild since it is installed by default with .NET Framework 2.0 and above.