Skip to content

Instantly share code, notes, and snippets.

@wlgrd
Created September 28, 2014 10:48
Show Gist options
  • Save wlgrd/8b0b5023d30d32b7352f to your computer and use it in GitHub Desktop.
Save wlgrd/8b0b5023d30d32b7352f to your computer and use it in GitHub Desktop.

Revisions

  1. wlgrd created this gist Sep 28, 2014.
    45 changes: 45 additions & 0 deletions msbuild_example
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    <?xml version="1.0" encoding="utf-8"?>
    <!--
    This files include my first example for MSBuild.
    It includes some properties (with condition), items and one target.
    Created mostly for future reference.
    -->

    <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- Metadata about build script -->
    <PropertyGroup>
    <ProductVersion>v1.0</ProductVersion>
    <!-- By not setting the config string, it will be set to Debug in the next if()-->
    <Configuration>Release</Configuration>
    <!-- If Configuration == ''; Configuration = Debug -->
    <Configuration Condition="'$(Configuration)' == '' ">Debug</Configuration>
    </PropertyGroup>

    <!-- Needed project files -->
    <PropertyGroup>
    <mainFile>main.c</mainFile>
    <headerFile>header.h</headerFile>
    <compileOutput>program.exe</compileOutput>
    </PropertyGroup>

    <ItemGroup>
    <!-- To differ between e.g. c-files, header files. Can also use wildcards for several files -->
    <cFiles Include ="$(mainFile)" />
    </ItemGroup>

    <Target Name="Build">
    <Message Text="====================================="></Message>
    <Message Text="Christian's first MSBuild"></Message>
    <Message Text="====================================="></Message>
    <Message Text="Product version: $(ProductVersion)"></Message>
    <Message Text="Configuration: $(Configuration)"></Message>
    <Message Text="Msbuild bin path: $(MSBuildBinPath)"></Message>
    <Message Text="====================================="></Message>
    <!-- -->
    <Message Text="Compiling @(cFiles, ', ')"></Message>
    <Exec Command ="gcc @(cFiles) -o $(compileOutput)"></Exec>

    </Target>
    </Project>