如何防止Visual Studio 2017构建javascript? [英] How to prevent visual studio 2017 from build javascript?
问题描述
我今天升级到VS2017,我看到每次我在我的网络应用程序项目中更改内容时 - 构建再次构建我的所有javascript(我正在使用webpack for client)。
这很酷,但需要花费很多时间,所以我很乐意配置它来停止构建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>
确保将打字稿文件包含为内容
Make sure you are including your typescript files as content
<ItemGroup>
<Content Include="**\*.ts" Exclude="$(GlobalExclude)" />
</ItemGroup>
将 tsconfig.json
文件添加到您的项目root并确保设置以下设置:
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创建一个名为 [ProjectName] .csproj.nuget.g.targets
的生成目标文件 obj
项目目录。此目标文件正在导入 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!