Friday, 28 December 2012

TypeScript and MSBuild example

This article expects you to have basic knowledge aboutMS BUILD and have installed typescript on your machine.

I have started to use TypeScript. Now when the page is compiled I need to compile those TS files into JavaScript.

As default TypeScript does not compile, we need to add out compilation in order for us to get JavaScript files

Definition of my example BuildTypeScript.msbuild

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="" DefaultTargets="BuildTypeScript" ToolsVersion="4.0" >


  <TypeScriptCompile Include="$(sourcedir)\**\*.ts" />

  <Target Name="BuildTypeScript" Inputs="@(TypeScriptCompile)" Outputs="%(Identity).Dummy">
  <Message Text="@(TypeScriptCompile)" />  
<Exec Command="&quot;$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript\$(TypeScriptVersion)\tsc&quot; -target ES5 &quot;@(TypeScriptCompile)&quot;" />

Check against your version:

  • I have added default value where is source of my project that you might need to update.
  • You need to check what version of type script has been installed on your local pc/build server

Command to execute:

msbuild BuildTypeScript.msbuild


No comments:

Post a Comment