Disable typescript compilation in Visual Studio 2013

淺唱寂寞╮ 提交于 2019-12-22 04:09:44

问题


I am running grunt and have set up a typescript build process that listens for file changes, therefore I don't need the default VS compilation of my typescript files when I save or build my project.

I have unchecked the 'Compile on save' option under typescript in my project properties, but the ts files are still being compiled. The only way this works for me is if I set the build action of individual TS files to 'None', but this is still causing some Typescript files to be compiled. Is there any way this can be done in VS2013?


回答1:


In VS2015, a <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> setting can be added to the first <PropertyGroup> element in .csproj

msbuild output should then show

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

From: http://rostacik.net/2015/08/14/how-to-disable-building-of-typescript-files-in-visual-studio-2015/




回答2:


I had the same question and solution that I found is to override TypeScript targets in the VS project file:

<Target Name="PreComputeCompileTypeScript">
  <Message Text="Skipping PreComputeCompileTypeScript" />
</Target>
<Target Name="CompileTypeScript">
  <Message Text="Skipping CompileTypeScript" />
</Target>
<Target Name="GetTypeScriptCopyToOutputDirectoryItems">
  <Message Text="Skipping GetTypeScriptCopyToOutputDirectoryItems" />
</Target>



回答3:


@Christopher Mott answer works also for Visual Studio 2013, at least for Update 5 and TypeScript Tools for Microsoft Visual Studio 2013 1.8.5.0. To be sure, one could verify if VS TypeScript toolchain understands that flag:

Open .csproj file for the intendend project and notice that it imports TypeScript targets from some:

$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets

that generally maps to:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\<your VS version number>\TypeScript\Microsoft.TypeScript.targets

Inspect that file and look for TypeScriptCompileBlocked being defined (as false) in some <PropertyGroup>. If it's there, you're sorted. Go back to .csproj file and add the following, right after where TypeScript targets are imported:

<!-- Disable TypeScript compilation from within VS, leave that to external tools -->
<PropertyGroup>
  <TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>



回答4:


Change the Build Action property on your TypeScript files to something other than TypeScript Compile



来源:https://stackoverflow.com/questions/27425417/disable-typescript-compilation-in-visual-studio-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!