Tuesday, January 14, 2014

TypeScript: TypeScript files inside a class library are not compiled

When you add TypeScript files to a class library and build the project, you’ll see that nothing happens. No matter what you try, no JavaScript files are created.
After comparing the csproj file with a MVC Web project, I noticed that a targets file is not referenced. I guess it’s a bug in the Visual Studio tooling…
To fix this, execute the following steps:
  • Unload the project
  • Edit the project file using an XML editor
  • Add the following line
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />

after

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • Save the file and reload the project
If you now try to build, the JavaScript files will be generated as expected.

1 comment:

parabol ink richie said...

Thanks for this. It solved my problem immediately