azure-devops - 使用 .NET Core 和 Angular 构建管道,但在发布任务期间发生 npm 构建?
问题描述
在解决方案中有一个 .NET Core 2.2 应用程序,并且一直在使用发布配置文件发布到开发服务器。现在,我设置了一个 Devops 构建管道以使用本地自托管代理进行发布。大部分工作,但我看不到正确的 npm 构建配置。
当我在本地使用我的发布配置文件时,我使用 csproj 文件中的设置来控制用于 npm 构建的选项。
例如。
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<!-- Use conditional builds based on build target setting eg. debug, dev, prod etc -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build " Condition=" '$(Configuration)' == 'Debug' " />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build --prod false --configuration=dev" Condition=" '$(Configuration)' == 'Test' " />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build --prod true --configuration=prod" Condition=" '$(Configuration)' == 'Release' " />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr --configuration=prod" Condition=" '$(BuildServerSideRenderer)' == 'true' And '$(Configuration)' == 'Release' " />
但是,我的构建管道中的 npm build 直到发布步骤才运行。然后它是默认的“ng build”,没有设置使用正确的角度环境值。
在 npm build 任务中,我将其用于自定义命令
构建 --prod 错误 --configuration=dev
但它似乎没有在构建过程中运行。
如何让正确的 npm 构建设置运行?
解决方案
a)我有同样的问题,我通过在脚本中添加一个新命令来更新 package.json 文件解决了这个问题(见附图)
"build-staging": "ng build --configuration=staging"
b) 我还更新了构建定义 npm build
c)我删除了publishrunwebpack 节点下 .csproj 文件 中的 exec 行e .csproj 文件
这导致根据环境运行正确的 nb build 命令。
推荐阅读
- html - 使用 [style.width.%] 以指数方式设置 div 的宽度
- javascript - DevEd 教程中的滚动功能不起作用
- javascript - ChartJS:悬停时在两个数据点之间画线
- php - 如何解决 WordPress/Cpanel 网站上的“作曲家依赖”问题?
- python-3.x - python asyncio 主动循环
- sql-server - 比较 column1(选项集)与 SSIS 中 column2(查找)中的设置值
- python - 使用原始层和简单地将字符串附加到数据包之间有什么区别吗?
- java - 获取两个日期之间的所有记录 spring boot jpa
- python - 如何在非二进制图像上使用 scipy.label
- discord.py - 试图让 on_member_update() 与我的不和谐机器人一起工作,但它不会向频道发送消息