Background:
We have several ASP.NET projects with common Core. Static from Core is copied to all other projects. We've added TypeScript to all our projects.
Here is how TypeScript build looks in csproj:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" />
When TypeScript files are compiled, all references files are compiled too. Some TypeScript files references files from Core project. So, files from Core project are sometimes compiled many times (if several files from other project references them).
Simple example:
Core.csproj
-> Common.ts
A.csproj
-> ScriptA.ts
B.csproj
-> ScriptB.ts
ScriptA.ts:
/// <reference path="../Core/Common.ts" />
...
ScriptB.ts:
/// <reference path="../Core/Common.ts" />
...
Build of A or B project causes Common.ts from Core to be built also.
Problem:
It's not a problem that some files are built several times. BUT - if we building projects in parallel (and this is default VS behaviour!) - sometimes build crashed with exception:
[VsTsc] VSTSC error TS5033: Build: Could not write file '...'
Reason is that two or more projects tries to build TypeScript files and tries to build referenced files from some common project. One project starts building ts file to js file and locks js file. Other project tries to lock the same file and crashes.
So, the question is - how to avoid such parallel builds/locks? Referenced project must be compiled already, so may be say TypeScript compiler not to build files from other projects somehow?