TypeScript tsconfig.json being ignored in C# project
TL;DR - Make sure your tsconfig.json file has the Build Action set to Content
I almost pulling out my hair in frustration, so I decided to dig in deeper to find out why this was happening. First, I ran msbuild with detailed logging. That showed up the following line just before the CompileTypeScript target was run:
Target "PreComputeCompileTypeScriptWithTSConfig" skipped, due to false condition; ('@(ConfigFiles)' != '') was evaluated as ('' != '').
A bit more digging led me to
packages\Microsoft.TypeScript.MSBuild.2.3.1\tools\net45\Microsoft.TypeScript.targets – This defines
PreComputeCompileTypeScriptWithTSConfig target which is looking for
which in turn is set in target
FindConfigFiles. That target calls the
that is in TypeScript.Tasks.dll.
Firing up JetBrains dotPeek to reflect on the code for FindConfigTasks shows that it uses the
ContentFiles property to look for existing tsconfig.json files, and that property is set to
@(Content) in the targets file.
Jumping back to my project, I notice this:
Ah haa! Let’s set that Build Action to Content and try again..
Yes! Building the project shows
tsc.exe being passed the
--project parameter pointing to the tsconfig.json file!