Search code examples
visual-studio-2015.net-coreasp.net-core-1.0

How to disable TypeScript compilation in .Net Core projects?


I have a Visual Studio 2015 ASP.Net Core project that contains a folder of typescript files.

My question is how can I prevent VS from trying to compile the TypeScript files? I don't want them compiled, either on save or build.

I have tried added the project setting below, but it doesn't seem to have any impact.

<PropertyGroup>
  <TypeScriptCompileOnSaveEnabled>False</TypeScriptCompileOnSaveEnabled>
</PropertyGroup>

Currently VS is throwing an error, tsc.exe exited with code 1, but as stated, I don't want the TS compiler to run at all.

I can disable the typescript.targets that VS uses, but that's not practical, because I need it for other projects.


Solution

  • I spent some time digging around in the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets file, and I found a support property that seems to do the job.

    Add this property to the project, by editing the project file directly and adding this property group:

    <PropertyGroup>
      <!-- Makes the TypeScript compilation task a no-op -->
      <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    </PropertyGroup>
    

    EDIT: @Chopin pointed out in the comments that the official doc for this and other Typescript MSBuild related options is here.