I'm hoping to stop including the generated JavaScript files in TFS source control, but I haven't managed to get the compiler to run on a build.
I've followed this chap's example and edited the project file to give me:
<ItemGroup>
<TypeScriptCompile Include="$(ProjectDir)\**\*.ts" />
</ItemGroup>
<Target Name="BeforeBuild">
<Message Text="Before Build" Importance="high" />
<CallTarget Targets="TypeScriptBuild"/>
</Target>
<Target Name="TypeScriptBuild" Inputs="@(TypeScriptCompile)" Outputs="%(Identity).Dummy" Condition="'$(CompileTypeScript)'=='true'">
<Message Text="Building typescript file - @(TypeScriptCompile)" Importance="high" />
<Exec Command=""$(MSBuildProgramFiles32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\tsc" -target ES3 "@(TypeScriptCompile)"" />
</Target>
I've changed the file location where the tsc executable is and removed the TypeScript version information, but it isn't doing anything for me. I'm a complete newbie at this build stuff so would appreciate any help, or tips on how to debug it.
Edit 1 Removed
<ItemGroup>
<TypeScriptCompile Include="$(ProjectDir)\**\*.ts" />
</ItemGroup>
as it was redundant - this is added individually for every TypeScript file in the project.
The only warnings I'm getting are about inconclusive unit tests. I assumed that <Message Text="Before Build" Importance="high" />
would produce some kind of log message but I can't see it anywhere.
Edit 2 Got it working locally within Visual Studio by putting
<Target Name="BeforeBuild">
<Message Text="Compiling typescript...">
</Message>
<Exec Command=""$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript\tsc" -target ES3 @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
at the end of the .csproj file. For some reason this doesn't work when TFS is building it. If I change the TypeScript compiler file location to something nonsensical it complains, but when it's correct there are no JavaScript files produced.