70
votes

For a Visual Studio projects such as a ASP.NET MVC5, how do you disable compiling of TypeScript files on build/debug?

I currently have tsconfig.json compileOnSave and buildOnSave set to false. Does something need to be added to the projects .csproj to ensure it isn't compiled?

When debugging the ASP.NET MVC5 project, it compiles all .ts files.

Thank you for any help you can provide.

4

4 Answers

141
votes

Add the property <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> to a PropertyGroup in your csproj file (I added it under the Configuration label). This should disable all msbuild based TS compilation.

With this setting enabled you shouldn't need the tsconfig.json settings compileOnSave/buildOnSave.

If you are on an older version of Visual Studio (I had implicitly thought about VS 2017 or xproj with 2015), the property may be <TypeScriptEnabled>false</TypeScriptEnabled>.

2
votes

I had this issue, tested all the things that was posted here without success,

But after adding this, things worked:

<TypeScriptToolsVersion>3.9</TypeScriptToolsVersion>

Seems like the version that I was using did compile no matter the settings.

1
votes

For Visual Studio 2015, adding below line under PropertyGroup helped me.

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
0
votes

None of the other solutions worked for me and this one caused an error on project load (VS 2019 - 16.9.4)

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>  // doesn't work for me

Another way of doing the same thing (albeit with very minor overhead) is to just remove all your TS from the compilation index.

<TypeScriptCompile Remove="*" />

I use this for avoiding compilation of node modules, like so:

<TypeScriptCompile Remove="node_modules\**" />