Introducing MSBuild

MSBuild.exe is a command-line tool that has been included in the .NET Framework since the 2.0 version and that can perform advanced and complex compilations. The Visual Basic compiler (the Vbc.exe tool) enables building an executable from multiple code files, but if you invoke it from the command line manually, you need to specify every single code file that must be compiled to produce the assembly; moreover, you are required to specify references, imports, and so on. The most important thing is that the VB compiler cannot build assemblies starting from neither project files nor from solution files. MSBuild goes beyond such limitations, providing the ability to build solutions (.sln files), including solutions composed by mixed projects, project files produced by Visual Studio (such as Visual Basic .vbproj files) and custom project files in one command line. For example, the following command line can build a solution without the need to invoke the compiler and specify all other requirements:

MSBuild MsBuildTest.sln

Command Prompt

To run MSBuild without specifying the .NET Framework path in the command line, start the Visual Studio command prompt available in the Visual Studio’s shortcuts folder in the Windows Start menu.

Figure 51.1 shows the build output in the Console window, where you can get details on the build process.

Figure 51.1 Building a project with MsBuild from the command line.

image

MSBuild is based on Xml files known as projects. Project files are easy to create, understand, and extend; projects are actually nothing new to you, because when you create projects with Visual Basic, these are compliant with the MSBuild Xml schema (http://schemas.microsoft.com/developer/msbuild/2003). This is the reason why you can build your projects with MSBuild. Basically a project contains all information required to build the final executables including code files, configuration properties, target options, and so on. Let’s see how a project is structured.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.51.129