1

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.

1
  • It sounds like you are new to MSBuild. You could also create a dummy C# class library project, add all your skbsrc files to the project as content and then put a postbuild command in to call your compiler. Not very elegant super easy. Commented Jul 19, 2014 at 0:38

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

That's a lot of infrastructure for simply shelling out to an EXE.
but it gives a lot of control, consider you can write tasks inline (msdn.microsoft.com/en-us/library/dd722601.aspx)
3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.