Search code examples
visual-studioasp.net-mvc-4build-processtypescript

Visual Studio - Before Build - TypeScript Compiling


Is there a way to setup a "BeforeBuild" step that compiles each TypeScript file to its own Javascript file in a specific directory? For instance, I would like all TypeScript files to compile to a individual Javascript files in the '\tsbuild' directory in the solution.

Right now the compiler is combining all of the TypeScript files into one Javascript file in a specified directory - which looks like this:

  <Target Name="BeforeBuild">
    <Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc&quot; --out @(TypeScriptCompile ->'&quot;$(ProjectDir)tsbuild\buildall.js&quot; &quot;%(fullpath)&quot; ', ' ')" />
  </Target>

Then, once they are in one directory, the goal is to configure the Bundle Configuration to pick them up and minify them during release. The other purpose is to help troubleshooting during development.


Solution

  • Once 0.8.2.0 is released (soon!) you'll be able to pass a directory to --out to get the desired behavior. For now, there isn't a particularly elegant way to do this.