arielorvits arielorvits - 14 days ago 9
Javascript Question

How to prevent visual studio 2017 from build javascript?

I upgraded today to VS2017, and I saw that every time I change something in my my web app project - the build build all my javascript again (I'm using webpack for client).
It is cool, but it take a lot of time, so I'll be happy to configure it to stop building the javascript (and I'll build it myself just when it changed).

thanks!

Answer

Simple Answer

In your csproj file, add the following line to the existing PropertyGroup block:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

Make sure you are including your typescript files as content

<Content Include="**\*.ts" Exclude="$(GlobalExclude)" />

Add a tsconfig.json file to your project root and make sure the following setting is set:

"disableCompileOnSave": true,

Details

Nuget creates a generated targets file called [ProjectName].csproj.nuget.g.targets in the obj directory of your project. This targets file is importing Microsoft.NET.Sdk.Web.ProjectSystem.targets which in turn imports Microsoft.TypeScript.targets.

In the Microsoft.TypeScript.targets file, the following line has a comment that lets us know that if this property is set to true, then the TypeScript compilation task will do nothing:

<!-- Makes the TypeScript compilation task a no-op -->
<TypeScriptCompileBlocked Condition="'$(TypeScriptCompileBlocked)' == ''">false</TypeScriptCompileBlocked>
Comments