30

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.

2 Answers 2

72

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Here is the official doc for this and other Typescript MSBuild related options.
It works. What I found annoying is that the new 1.1.1 release of Asp.net core introduces some Typescript targets that do not work with VS 2015 but only with VS 2017. By adding this property group, all works, especially because I don't use Typescript at all :-)
Can someone please explain to me why this isn't a checkbox? It seems to be a pretty majorly useful option.
This isn't working for me on VS 2019.16.10.2. Oddly when there is any C# Error, then I see many TS errors.. When no C# error, no TS errors.
0

this trick indeed works for new version of MSBuild. However if you still have older versions of MSBUild, on a build server or so. You also want to remove these lines from the csproj file.

  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />

   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />

Regards

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.