1. When is the compileTypeScript target actually executed?
CompileTypeScript has been added to the CompileDependsOn list, this list is defined here: "C: \ Program Files (x86) \ MSBuild \ 12.0 \ Bin \ Microsoft.Common.CurrentVersion.targets". The default target (usually builds) depends on CoreBuild, which in turn requires the compilation target to be completed, see Target compiler (line 2762) and target corebuild (line 703).
So, when the goal is built, it builds TypeScript, because the assembly requires BeforeBuild, CoreBuild, and AfterBuild to run. The CoreBuild target requires many goals, including compilation, and TypeScipt is added to the Microsoft.TypeScript.targets file ("C: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v12.0 \ TypeScript \ Microsoft.TypeScript.targets") . Cm:
<PropertyGroup> <CompileDependsOn> CompileTypeScript; $(CompileDependsOn); </CompileDependsOn> </PropertyGroup>
2. What does PreComputeCompileTypeScript do?
It tries to find the most common path for the outDir option when using it. Also, when there are no TypeScript files, this task is the one that gives the error: the files are not compiling (or something else). When a single output (the -out option) is defined, it does different things. It seems that VS VS provides the full path to the compiler, and this task makes them relative whenever possible (I don't know the reasons for this, though).
3. Is there a way to suggest that the MSBuild target be executed before the TypeScript build?
When creating your own msbuild task, you can change the compileDependsOn target. You must do this after importing Microsoft.TypeScript.targets. You can change it as follows:
<PropertyGroup> <CompileDependsOn> CompileYourTarget; $(CompileDependsOn); </CompileDependsOn> </PropertyGroup>
edit: I am changing part 2 of the answer