問題描述
我今天升級到 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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!