Ezra Bailey
Ezra Bailey

Reputation: 1443

msbuild custom compiler/build script

I'm attempting to use TFS and MSBuild as a build and source control for a non-.NET project. This project contains a series of individual called .skbsrc files, that each compile into a .skb file. I'm trying to figure out if it's possible to use MSBuild in a way to build these files.

Say I'm using the example on the msdn website:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Compile Include="testfile.skbsrc" />
  </ItemGroup>
  <Target Name="Build">
    <Csc Sources="@(Compile)"/>  
  </Target>
</Project>

Csc is clearly used for C# code, and runs the csc.exe program. Is there a way I can make a block like this for my own compiler (skbuilder) so I could run like:

<Skbuilder Sources="@(Compile)" />

which in turn would run

>skbuilder testfile.skbsrc

If this is possible with msbuild, could anyone post an example? I've been unable to find anything in my searches.

Thank you so much.

Upvotes: 1

Views: 721

Answers (2)

Christopher Painter
Christopher Painter

Reputation: 55620

Take a look at the Exec Task.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <SourceFiles Include="*.skbsrc"/>
    </ItemGroup>

    <Target Name="Build">
        <Exec Command="skbuilder &quot;%(SourceFiles.Identity)&quot;"/>
    </Target>

</Project>

You'll also need to pass an argument to your skbuilder program telling it to output it's files to the $(OutDir) directory or use Copy Task to pick up *.skb to $(OutDir). Use quotes around the argument incase the TFS workspace path has spaces in it.

Finally you can test this on your own machine without using TFS by creating a simple .BAT file:

set PATH=%CD%;C:\Windows\Microsoft.NET\Framework\v4.0.30319
msbuild build.proj > build.log

Upvotes: 3

Matt
Matt

Reputation: 6050

You can create a customized task in msbuild to do it. "CSC" is a default task in C#, so what you need is to implement a similar task for your exe.

This MSDN article explains how to write a task for msbuild.

Upvotes: 3

Related Questions