Gareth's Blog‎ > ‎

TypeScript & Apphabor

posted 27 Oct 2012, 12:55 by Gareth Rylance   [ updated 28 Oct 2012, 00:10 ]
I recently learned about the hosting platform Appharbor and have been looking for a project to use it for. As mainly C# developer I have not had a reason or the time to properly explore JavaScript.The release of Typescript has lowered the barrier into the JavaScript world enough for to start to play.  I plan to post any interesting things I find here. 

The first thing I needed was somewhere to deploy any interesting code I write. This is were Apphabor comes in. A small change to the default TypeScript project will allow the project to be deployed into Apphabor. Apphabor does not know how to compile Typescript files into JavaScript so in order to use it for a TypeScript project you must add the  TypeScript compiler into your project and alter the default .csproj file to use it. 

The default location of the compiler is $(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\ I copied the TypeScript folder into my Visual studio solution directory. I then altered my .csproj file (by first unloading it) to use the copied compiler. The altered before build target is given below.

  <Target Name="BeforeBuild">
    <Exec Command="&quot;$(SolutionDir)TypeScript\0.8.0.0\tsc&quot; @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />
  </Target>


You must also add the created JavaScript files into you Visual Studio project and set them to be copied to the output directory on deployment. The files themselves do not need to be checked into source control as they will be generated from the TypeScript files.


With the above alterations a project checked into Apphabor will compile the TypeScript files and deploy the JavaScript files created. 


I think that is it but I will update this post if I missed anything.


Comments