MS Build comes with the .NET Framework itself and the executable (msbuild.exe) is located in the .NET-framework directory, something like (depending on version):
- C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
- C:\WINDOWS\Microsoft.NET\Framework\v3.5
- C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
(The right version is also in %path% when using the "Visual Studio command prompt" from the start menu.)
MsBuild files are xml-files. You can start by making a new text file, lets say "c:\myscript.msbuild", and copy-paste this to the file:
<Project DefaultTargets="MyTarget" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="MyTarget">
<Message Text="Hello world!" Importance="high"/>
</Target>
</Project>
Then go to command prompt and type:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe c:\myscript.msbuild
That is a good start. :)
Then you can customize the targets and properties.
Second example:
<Project DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(MyCondition)' == 'x'" >
<MyProperty>World2</MyProperty>
</PropertyGroup>
<Target Name="MyTarget">
<Message Text="Hello" Importance="high"/>
<Message Text="$(MyProperty)" Importance="high"/>
</Target>
<Target Name="MyTarget2">
</Target>
<Target Name="All">
<CallTarget Targets="MyTarget" />
<CallTarget Targets="MyTarget2" />
</Target>
</Project>
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe c:\myscript.msbuild /target:mytarget /property:MyCondition=x
You can have also build files inside build-files.
<Project DefaultTargets="MyTarget" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="MyExternalProperties.msbuild"/>
<Target Name="MyTarget">
<Exec Command="echo Hello world 3"/>
</Target>
</Project>