Reputation: 38847
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.
Upvotes: 107
Views: 42588
Reputation: 63
Maybe this will help someone:
My observation in VS2022 is, that these and some other properties are somehow ignored when Tools -> Environment -> Preview Features -> Use previews of .NET SDK (requires restart) is enabled
Upvotes: 0
Reputation: 146190
There's an issue related to this which has been open for years. Still doesn't seem to be a way to turn it off for website projects.
The following seemed to work best for me (under Tools > Options > TextEditor > JavaScript/TypeScript > Project > General) to greatly reduce errors in the console.
Upvotes: 0
Reputation: 11285
As mentioned here, you can 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>
.
Upvotes: 197
Reputation: 387
I had all of this configured, but it still did not fix the issue (in visual studio 2019). I added additionally this:
<TypeScriptCompileOnSaveEnabled>False</TypeScriptCompileOnSaveEnabled>
and restarted the visual studio. After that, it started working for me.
Upvotes: 7
Reputation: 755
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\**" />
Upvotes: 5
Reputation: 1640
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.
Upvotes: 2
Reputation: 119
For Visual Studio 2015, adding below line under PropertyGroup helped me.
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
Upvotes: 4