如何在 .Net Core 项目中禁用 TypeScript 编译? [英] How to disable TypeScript compilation in .Net Core projects?
问题描述
我有一个包含打字稿文件文件夹的 Visual Studio 2015 ASP.Net Core 项目.
I have a Visual Studio 2015 ASP.Net Core project that contains a folder of typescript files.
我的问题是如何防止 VS 尝试编译 TypeScript 文件?我不希望在保存或构建时编译它们.
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>
当前 VS 正在抛出错误,tsc.exe 以代码 1 退出
,但如上所述,我根本不希望 TS 编译器运行.
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.
我可以禁用 VS 使用的 typescript.targets,但这不实用,因为我需要它用于其他项目.
I can disable the typescript.targets that VS uses, but that's not practical, because I need it for other projects.
推荐答案
我花了一些时间在 C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0TypeScriptMicrosoft.TypeScript.targets
文件,我发现了一个似乎可以完成这项工作的支持属性.
I spent some time digging around in the C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0TypeScriptMicrosoft.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>
@Chopin 在评论中指出,这个和其他 Typescript MSBuild 相关选项的官方文档是 此处.
@Chopin pointed out in the comments that the official doc for this and other Typescript MSBuild related options is here.
这篇关于如何在 .Net Core 项目中禁用 TypeScript 编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!