禁用 MSBuild TypeScript 编译

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42430300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:17:17  来源:igfitidea点击:

Disable MSBuild TypeScript Compile

asp.netvisual-studiotypescriptmsbuild

提问by Alexander Staroselsky

For a Visual Studio projects such as a ASP.NET MVC5, how do you disable compiling of TypeScript files on build/debug?

对于 ASP.NET MVC5 等 Visual Studio 项目,如何在构建/调试时禁用 TypeScript 文件的编译?

I currently have tsconfig.jsoncompileOnSaveand buildOnSaveset to false. Does something need to be added to the projects .csprojto ensure it isn't compiled?

我目前拥有tsconfig.jsoncompileOnSavebuildOnSave设置为false。是否需要将某些内容添加到项目中.csproj以确保它不被编译?

When debugging the ASP.NET MVC5 project, it compiles all .tsfiles.

在调试 ASP.NET MVC5 项目时,它会编译所有.ts文件。

Thank you for any help you can provide.

感谢您提供任何帮助。

回答by Fionn

Add the property <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>to a PropertyGroup in your csproj file (I added it under the Configuration label). This should disable all msbuild based TS compilation.

将该属性添加<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>到 csproj 文件中的 PropertyGroup(我将其添加到 Configuration 标签下)。这应该禁用所有基于 msbuild 的 TS 编译。

With this setting enabled you shouldn't need the tsconfig.json settings compileOnSave/buildOnSave.

启用此设置后,您不需要 tsconfig.json 设置 compileOnSave/buildOnSave。

If you are on an older version of Visual Studio (I had implicitly thought about VS 2017 or xproj with 2015), the property may be <TypeScriptEnabled>false</TypeScriptEnabled>.

如果您使用的是较旧版本的 Visual Studio(我曾隐含地考虑过 VS 2017 或 xproj 与 2015),则该属性可能是<TypeScriptEnabled>false</TypeScriptEnabled>.