加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

在dotnet发布后运行角度生产版本

发布时间:2020-12-16 06:40:37 所属栏目:asp.Net 来源:网络整理
导读:我有一个ASP.NET Core 2.0应用程序和Angular 5 SPA托管在同一个文件夹中. 目前要部署到IIS,我执行以下操作: // First publish the release configurationdotnet publish -c release // Now delete the wwwroot directory as it is pulished with ng buildrm
我有一个ASP.NET Core 2.0应用程序和Angular 5 SPA托管在同一个文件夹中.

目前要部署到IIS,我执行以下操作:

// First publish the release configuration
dotnet publish -c release 
// Now delete the wwwroot directory as it is pulished with ng build
rm -r bin/release/netcoreapp2.0/publish/wwwroot
// Build the prod version of the angular app
ng build --prod
// copy the new wwwroot folder into the publish folder
cp -R wwwroot bin/release/netcoreapp2.0/publish/

这非常令人沮丧……我怎么能告诉dotnet发布运行ng build -prod?

我已经尝试将以下内容添加到我的项目csproj文件中:

<Target Name="AngularBuild" AfterTargets="Publish">
  <Exec Command="npm run build --prod" />
</Target>

解决方法

您可以使用任何将逐个调用所有这些命令的任务运行器或自定义脚本.

例如,您可以在package.json中定义自定义npm脚本:

{
  ...
  "scripts": {
    "apppublish": "dotnet publish -c release && npm run build --prod",...
  }
}

然后在需要发布应用时调用npm run apppublish.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读