【发布时间】:2018-05-04 14:04:06
【问题描述】:
设置:
- ASP.Net MVC 5 应用程序 (v4.5.2)。
- Angular (v5.2.0) 在 MVC 应用程序中使用 angular-cli(v1.7.4)。
- Angular 应用程序在 www.mydomain.com/app 上运行。
- Angular 应用程序加载到 AppController 的索引视图中。
- 使用 BundleConfig.cs 引用 dist 文件夹中必要的 JS 和 CSS 输出文件。
- 构建过程已修改为使用 .csproj 文件构建 Angular 应用程序。
- ng build 使用 -extract-css(-ec),因此 Index.cshtml 文件不必在开发和生产之间进行更改。
- 到目前为止一切正常。
.csproj:
<Target Name="NgDebug" BeforeTargets="Build" Condition="'$(Configuration)' == 'Debug'">
<Exec WorkingDirectory="$(ProjectDir)admin-client" Command="ng build -ec" />
</Target>
<Target Name="NgRelease" BeforeTargets="Build" Condition="'$(Configuration)' == 'Release'">
<Exec WorkingDirectory="$(ProjectDir)admin-client" Command="ng build --prod" />
</Target>
问题:
- 将 --watch (-w) 添加到
Command="ng build -ec"时,构建将无限期挂起并且不会引发任何错误。 - 构建输出挂起:
1>------ Build started: Project: CorpNet.Admin.Web, Configuration: Debug Any CPU ------
我的解决方案:
应用程序启动后,我通过命令行运行 ng build -ec -w 并且一切正常。
问题:
如何将--watch (-w) 添加到ng build -ec 作为构建过程的一部分,而不是从命令行手动运行?
【问题讨论】:
标签: asp.net-mvc angular asp.net-mvc-5 angular-cli csproj