Problematic Typescript to deal with again!
Here's what I have. It builds fine on Save but simply won't build at all on compile. I'm loathe to follow too many instructions on the internet as so many different methods to get this working seem to exist. This is what I've tried:
Checking that TypeScriptCompile action is set on files
I've added the property group section (which seems to have got compile on save working) This has solved this problem in the past.
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />
The only other compilicating factor is that I'm using Durandal and therefore I have added my typescript objects into this structure: App/viewModels
and App/modules
.
Ok,
I finally fixed this by creating a Typescript HTML project and doing some comparisons between my MVC 5.0 where I wanted to use typescript and the Typescript HTML project where all was working well.
What worked for was the above lines of code needed to be added after the </ProjectExtensions>
. So I now have:
</ProjectExtensions>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets')" />
Note the slight differences ES3 becomes ES5 and the $(VSToolsPath)
project path.
So it appears it the order in which these things occur. I think overall an upgrade to VS 2013 might be in order where I believe a lot of these problems are fixed.