Friday, May 22, 2009

MSBuild Quick Start

Hi,

Today i configured MSBuild in my laptop, though Microsoft has given a detailed installation for configuring MSBuild , how ever i would like to put it in simple steps starting from configuring MSBuild and creating a sample build .

Pre-requisites:
  1. Assume you have already installed .NET framework in your machine. If not you can download from the following link. Click Here
  2. Assume you have already installed .NET framework SDK in your machine.If not you can download from the following link. Click Here
Configuring MSBuild :
  1. Start >> right click on My Computer and Properties.
  2. Go to Advance Tabs >> Click on Environment Variables.
  3. In System Variables look for "Path" and click Edit.
  4. Make sure you the following paths are set, if not please update and click ok.
  • C:\WINDOWS\Microsoft.NET\Framework\version number;
  • C:\Program Files\Microsoft.NET\SDK\version number\bin
Now go to Start >> Run and type "cmd" to open a command prompt.
type: msbuild and hit enter. then you will see the MSBuild with a version number and an MSBuild error.


Don't worry about Error, it means MSBuild is running successfully on your PC.

Next Step is creating a sample build for any .Net project.

For demonstration let's create a build for "Helloworld" .Net Project, If you don't have the project you can download from here: Click Here

Download and Extract to C Drive, so your extracted folder looks like this : c:\helloworld
  1. Hello.cs (C# file)
  2. HelloWorld.proj (Build file)

Now you have to run HelloWorld.proj file to create a build using MSBuild.
To know more about .Proj file you can visit Microsoft site: Click Here.

Your HelloWorld.proj is the jist of the project that you are going to create a build.

Now go to command prompt and change the directory :
  1. cd c:\HelloWorld
  2. c:\HelloWorld>msbuild HelloWorld.proj
Out put should be as follows:

You see an HelloWorld.exe file created in C:\HelloWorld folder.

So, that's all you have created build for hello.cs file.

To test HelloWorld.exe you can just type HelloWorld.exe from HelloWorld directory.

Then the output would be "Hello World !"

Please share your thoughts and feedback to improve this article.

Kumar.

No comments:

Post a Comment