Hello World
HelloWorld.proj
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="SayHello">
<!-- Properties can be passed as command line parameters. i.e. /p:Name=MyName
or /p:Name="My Name" (Use quotes if the value includes spaces) -->
<PropertyGroup>
<Name Condition="'$(Name)'==''">Rolo</Name>
</PropertyGroup>
<!-- Items can't be passed as command line parameters. -->
<!-- Items can include metadata. i.e. URL -->
<ItemGroup>
<People Include="World"/>
<People Include="StackOverflow">
<URL>http://stackoverflow.com</URL>
</People>
<People Include="Google">
<URL>http://google.com</URL>
</People>
</ItemGroup>
<!-- Targets can be called using it's name. i.e. /t:SayHello -->
<Target Name="SayHello">
<!-- You can have as many Tasks as required inside a Target. -->
<!-- Tasks can be executed conditionally. -->
<Message Condition="'%(People.URL)'==''" Text="Hello %(People.Identity), my name is $(Name)! "/>
<Message Condition="'%(People.URL)'!=''" Text="Hello %(People.Identity), my name is $(Name)!. Your URL is %(People.URL) "/>
</Target>
</Project>
执行:
- msbuild HelloWorld.proj
- msbuild HelloWorld.proj / p:Name =
John Doe
- msbuild HelloWorld.proj / p:Name =
Batman
/ t:SayHello