E.Meir
E.Meir

Reputation: 2226

VS 2015 & msbuild suppress typescript errors

In the solution that I am using, there is one projects that heavily use typescript, I am trying to get this project to pass build in order to run msbuild on it..

Already tried editing .csproj file of the project that uses typescript and add to it the property <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

under <PropertyGroup> element, but this didn't help. also tried: <TypeScriptEnabled>false</TypeScriptEnabled> and this didn't help either.

How can i set VS2015 to ignore typescript and also what can i add to 'msbuild' command for it to ignore typescript also?

This is the Error List tab after Build: Error List

This is Output tab after Build: enter image description here

Upvotes: 2

Views: 1891

Answers (1)

Leo Liu
Leo Liu

Reputation: 76920

How can i set VS2015 to ignore typescript and also what can i add to 'msbuild' command for it to ignore typescript also?

Not sure the reason why all examples on that post did not work for you, I test the the property <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> on Visual Studio 2015 and it works fine. In order to ensure that you are operating correctly, I would like provide detail info about this method, you can check it.

Add node:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

Into the first <PropertyGroup> in .csproj file, like below:

<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  <ProductVersion>
  </ProductVersion>
  ....
  <NuGetPackageImportStamp>
  </NuGetPackageImportStamp>
  <TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
  <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>

After save this setting, reload your project, re-build the project(with MSBuild project build output verbosity to Detail), you will notice the build log in the output window:

TypeScript compile is skipped because the TypeScriptCompileBlocked property is set to 'true'.

enter image description here

Note:The version of TypeScript tools for Visual Studio is 1.8.36.0

Update:

then i looked at the "Output" tab but there is no line that contains the text "typescript" the lines there are not related to it

You should change MSBuild project build output verbosity to Detail, then check the log in output window:

enter image description here

I would like provide another method to suppress typescript errors:

Select the TypeScript file and change it's ContentType to 'Content' instead of 'TypeScriptCompile', then the language service should not give you errors on it.

  <ItemGroup>
    <Content Include="Test.ts" />
  </ItemGroup>

Update for comment:

If you want suppress TS error when you execute the build from MSBuild command, you can add the property as /p:TypeScriptCompileBlocked=true:

Detail info:

  1. open a cmd and switch the path to the MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

  2. Execute the command: msbuild "YourProject.csproj" /p:Platform=x64 /p:TypeScriptCompileBlocked=true

Upvotes: 6

Related Questions