How to disable TypeScript compilation in .Net Core projects?

前端 未结 2 632
盖世英雄少女心
盖世英雄少女心 2020-12-09 15:50

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 TypeScr

相关标签:
2条回答
  • 2020-12-09 16:18

    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.

    0 讨论(0)
  • 2020-12-09 16:30

    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

    0 讨论(0)
提交回复
热议问题