Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable MSBuild TypeScript Compile

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.

like image 519
Alexander Staroselsky Avatar asked Feb 24 '17 03:02

Alexander Staroselsky


People also ask

How to turn off TypeScript compilation in visual studio?

Fortunately, it's easy to disable automatic TypeScript compilation. Just add a “TypeScriptCompileBlocked” element to your project's xproj file and give it a value of “True”. This will prevent Visual Studio from making those pesky extra files.

How do I remove TypeScript from Visual Studio?

It is possible to manually remove TypeScript support by editing the project file in notepad, but is there a GUI in VS that handles this? Side note: Why on Earth would you use Notepad when you have Visual Studio??? Just right-click | Unload Project , then right-click | Edit {project name here} .

What is TypeScriptToolsVersion?

This allows a project to build against the same versions of the compiler on different machines. If TypeScriptToolsVersion is not specified, the latest compiler version installed on the machine will be used to build.

How do I install Microsoft TypeScript MSBuild?

right-click the project node and choose Manage NuGet Packages. In the Browse tab, search for Microsoft. TypeScript. MSBuild, and then click Install on the right to install the package.


1 Answers

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>.

like image 163
Fionn Avatar answered Sep 20 '22 01:09

Fionn