如何防止 Visual Studio 2017 构建 JavaScript?

How to prevent visual studio 2017 from build javascript?(如何防止 Visual Studio 2017 构建 JavaScript?)
本文介绍了如何防止 Visual Studio 2017 构建 JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我今天升级到 VS2017,我看到每次我在我的 web 应用程序项目中更改一些东西 - 构建再次构建我所有的 javascript(我使用 webpack 作为客户端).这很酷,但需要很多时间,所以我很乐意将它配置为停止构建 javascript(我会在它发生变化时自己构建它).

I upgraded today to VS2017, and I saw that every time I change something in my my web app project - the build build all my javascript again (I'm using webpack for client). It is cool, but it take a lot of time, so I'll be happy to configure it to stop building the javascript (and I'll build it myself just when it changed).

推荐答案

简单回答

在您的 csproj 文件中,将以下行添加到现有的 PropertyGroup 块:

Simple Answer

In your csproj file, add the following line to the existing PropertyGroup block:

<PropertyGroup>
     <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>

如果将 .ts.tsx 文件添加到您的项目会导致您的项目文件被修改,您可能需要应用以下修复.请参阅 错误报告 了解更多详情.

If adding .ts or .tsx files to your project causes your project file to be modified, you may need to apply the following fix. See the bug report for more details.

 <ItemGroup>
      <None Remove="**/*.ts;**/*.tsx" />
      <Content Remove="**/*.ts;**/*.tsx" />
      <TypeScriptCompile Include="**/*.ts;**/*.tsx" />
 </ItemGroup>

tsconfig.json 文件添加到您的项目根目录并确保设置了以下设置:

Add a tsconfig.json file to your project root and make sure the following setting is set:

"compileOnSave": false,

最后,重启 Visual Studio

Finally, Restart Visual Studio

Nuget 在项目的 obj 目录中创建一个名为 [ProjectName].csproj.nuget.g.targets 的生成目标文件.此目标文件正在导入 Microsoft.NET.Sdk.Web.ProjectSystem.targets,而后者又会导入 Microsoft.TypeScript.targets.

Nuget creates a generated targets file called [ProjectName].csproj.nuget.g.targets in the obj directory of your project. This targets file is importing Microsoft.NET.Sdk.Web.ProjectSystem.targets which in turn imports Microsoft.TypeScript.targets.

Microsoft.TypeScript.targets 文件中,以下行有一条注释让我们知道如果此属性设置为 true,那么 TypeScript 编译任务将不执行任何操作:

In the Microsoft.TypeScript.targets file, the following line has a comment that lets us know that if this property is set to true, then the TypeScript compilation task will do nothing:

<!-- Makes the TypeScript compilation task a no-op -->
<TypeScriptCompileBlocked Condition="'$(TypeScriptCompileBlocked)' == ''">false</TypeScriptCompileBlocked>

这篇关于如何防止 Visual Studio 2017 构建 JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
Ordinals in words javascript(javascript中的序数)
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)