Finally, after two days trying to figure out why TypeScript was not building a load of TypeScript files in Visual Studio I've tracked and fixed the problem...sort of...
Anyway, got latest and build the solution. Only to find, that for every TypeScript project (unlucky 13 in this case) failed to build. Looking at the error, each project was coming up with a useless generic error message stating that the build "exited with code 1". Yeah, thanks for the detail on that.
Anyhow, looking at the build output wasn't helping too much either.
So, I checked my machine to make sure it was using the same version as the other devs, which it was.
All good there as well.
For the rest of the day, I went through the process of googling, checking more settings on my machine, fiddling with project settings and generally going around in circles.
Anyway, after looking at this I didn't see any glaring issues. After more googling and getting nowhere fast I un-installed all versions of TypeScript, and re-installed each in turn.
Still no joy.
So, next was to un-installed Visual Studio 2005 Preview (which didn't do a good job) and re-installed Visual Studio 2013. Rebooted a few times, cleaned up my Path environment variable which TypeScript manage to forget about.
After all this, it was still stuffed!! :(
Can I compile a JavaScript file from the command line. Yes
Does the same file build through Visual Studio. No
What's the difference?
Looking at one of the csproj files it is using a Microsoft.TypeScript.targets build file.
Opening this up in Visual Studio reveals a build config file.
I happened to re-build the solution again and found a slightly different error. msb6006 tsc.exe
Looking at the build output identified a problem at line 96.
Line 96 is the opening VsTsc tag. Now I'm getting somewhere.
So, it looks like one of the variables is incorrect.
Everything looked good, and was resolving correctly. But I decided to uncomment the TscToolPath that was pointing to my installed SDK and ignore the local one. I also hardcoded the version.
Guess what? It worked!!!
So, there is some issue with the version of TypeScript being used in the one used by the solution.
I've not done this yet, but the TypeScriptToolsVersion element is not recognized by Visual Studio, which is hinting to maybe an incorrect version of the TypeScript Add-In or something on those lines.
But, I don't care at the moment. It's Friday, and got it all working before the weekend!
Two days ago...
So, I need to make some changes to web applications developed by another team. All good, I'll just get it from TFS, build it and go from there. Yes, I know, TFS is a bag of spanners, but you've got to work with what you have sometimes.Anyway, got latest and build the solution. Only to find, that for every TypeScript project (unlucky 13 in this case) failed to build. Looking at the error, each project was coming up with a useless generic error message stating that the build "exited with code 1". Yeah, thanks for the detail on that.
Anyhow, looking at the build output wasn't helping too much either.
So, I checked my machine to make sure it was using the same version as the other devs, which it was.
All good there as well.
For the rest of the day, I went through the process of googling, checking more settings on my machine, fiddling with project settings and generally going around in circles.
Yesterday
I found that there was an MSBUILD configuration which was specifying to use a local copy of TypeScript instead of the installed version. The only reason I can think of was to do with server build configurations.Anyway, after looking at this I didn't see any glaring issues. After more googling and getting nowhere fast I un-installed all versions of TypeScript, and re-installed each in turn.
Still no joy.
So, next was to un-installed Visual Studio 2005 Preview (which didn't do a good job) and re-installed Visual Studio 2013. Rebooted a few times, cleaned up my Path environment variable which TypeScript manage to forget about.
After all this, it was still stuffed!! :(
Today
So, today I went back to basics.Can I compile a JavaScript file from the command line. Yes
Does the same file build through Visual Studio. No
What's the difference?
Looking at one of the csproj files it is using a Microsoft.TypeScript.targets build file.
Opening this up in Visual Studio reveals a build config file.
I happened to re-build the solution again and found a slightly different error. msb6006 tsc.exe
Looking at the build output identified a problem at line 96.
<Target Name="PreComputeCompileTypeScript">
<VsTsc
ToolPath="$(TscToolPath)"
ToolExe="$(TscToolExe)"
Configurations="$(TypeScriptBuildConfigurations) COMPUTE_PATHS_ONLY"
FullPathsToFiles="@(TypeScriptCompile)"
YieldDuringToolExecution="$(TscYieldDuringToolExecution)"
OutFile="$(TypeScriptOutFile)"
OutDir="$(TypeScriptOutDir)"
ProjectDir="$(ProjectDir)"
>
Line 96 is the opening VsTsc tag. Now I'm getting somewhere.
So, it looks like one of the variables is incorrect.
<PropertyGroup>
<TypeScriptToolsVersion Condition="'$(TypeScriptToolsVersion)'==''">1.0</TypeScriptToolsVersion>
<!--<TscToolPath Condition="'$(TscToolPath)' == ''">$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript</TscToolPath>-->
<TscToolPath Condition="'$(TscToolPath)' == ''">$(SharedBinariesTypeScriptToolPath)</TscToolPath>
<TscToolPath Condition="'$(TypeScriptToolsVersion)' != ''">$(TscToolPath)\$(TypeScriptToolsVersion)</TscToolPath>
<TscToolExe Condition="'$(TscToolExe)' == ''">tsc.exe</TscToolExe>
<TscYieldDuringToolExecution Condition="'$(TscYieldDuringToolExecution)' == ''">true</TscYieldDuringToolExecution>
</PropertyGroup>
Everything looked good, and was resolving correctly. But I decided to uncomment the TscToolPath that was pointing to my installed SDK and ignore the local one. I also hardcoded the version.
Guess what? It worked!!!
So, there is some issue with the version of TypeScript being used in the one used by the solution.
The weird bit...
So, I'm writing this blog entry to explain the steps and went back to the version of Microsoft.TypeScript.targets that was not working so I can show the original settings. Re-compiled the solution to get the exact error messages and it still built!!!I've not done this yet, but the TypeScriptToolsVersion element is not recognized by Visual Studio, which is hinting to maybe an incorrect version of the TypeScript Add-In or something on those lines.
But, I don't care at the moment. It's Friday, and got it all working before the weekend!