Building HelloWorld from the command line with msbuild

I know I have blogged previously about building with msbuild. Here is a simplified sample that can get you started with using msbuild as your build tool.
There are 3 files involved, all located in the same directory: build.bat (batch file to execute the build process), build.targets (the targets file used by msbuild), and HelloWorld.cs (the source code being built into the executable).
@echo off
C:WINDOWSMicrosoft.NETFrameworkv2.0.50727msbuild build.targets
You will, obviously, have to adjust the path the msbuild in build.bat if it is not installed in its default location.
<Project xmlns="">
 <Target Name="Build">
      <Csc Sources="HelloWorld.cs" OutputAssembly="hello.exe"/>
using System;
namespace Hello {
    public class World {
        public static void Main(string[] args) {
                Console.WriteLine("Hello World!");
The output creates hello.exe in the same folder as the code.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s