Primeros pasos con msbuild

Hola Mundo


<Project xmlns="" 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) -->  
        <Name Condition="'$(Name)'==''">Rolo</Name>

    <!-- Items can't be passed as command line parameters. -->   
    <!-- Items can include metadata. i.e. URL -->  
        <People Include="World"/>  
        <People Include="StackOverflow">  
        <People Include="Google">  

    <!-- 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) "/>  

Ejecutar con:

  • msbuild HelloWorld.proj
  • msbuild HolaMundo.proj /p:Nombre=“Juan Pérez”
  • msbuild HelloWorld.proj /p:Nombre=“Batman” /t:Di hola

Instalación o configuración

##MSBuild 2015 En Windows hay tres opciones para obtener MSBuild:

en linux

  • Cree desde el código fuente utilizando esta guía

Creación de objetivos personalizados de MSBuild

     <!-- Definition of a Property named "TestCondition". A PropertyGroup may also be placed inside a Target. -->

<!-- This Target will run after the "Clean" Target, subject to a Condition. -->
<Target Name="SpecificTarget" AfterTargets="Clean" Condition=" '$(TestCondition)' == 'True' ">
    <!-- Displaying a custom message -->
    <Message Text="Here is my Specific Target" Importance="Low" />
    <!-- Here come your specific code. -->