msbuild Handledning
Komma igång med msbuild
Sök…
Anmärkningar
Det här avsnittet ger en översikt över vad msbuild är och varför en utvecklare kanske vill använda den.
Det bör också nämna alla stora ämnen inom msbuild och länka till relaterade ämnen. Eftersom dokumentationen för msbuild är ny kan du behöva skapa initialversioner av relaterade ämnen.
Installation eller installation
MSBuild 2015
På Windows finns det tre alternativ att få MSBuild:
- Installera Visual Studio 2015
- Ladda ner Microsoft Build Tools som innehåller VB- och C # -kompilatorer.
- Bygg från källan
På Linux
- Bygg ut från källan med hjälp av den här guiden
Skapa anpassade MSBuild-mål
<PropertyGroup>
<!-- Definition of a Property named "TestCondition". A PropertyGroup may also be placed inside a Target. -->
<TestCondition>True</TestCondition>
</PropertyGroup>
<!-- 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. -->
</Target>
Hej världen
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>
Kör med:
- msbuild HelloWorld.proj
- msbuild HelloWorld.proj / p: Namn = "John Doe"
- msbuild HelloWorld.proj / p: Namn = "Batman" / t: SayHello
Modified text is an extract of the original Stack Overflow Documentation
Licensierat under CC BY-SA 3.0
Inte anslutet till Stack Overflow