angular 6 VSTS azure 构建 ng 构建配置=生产不工作

angular 6 VSTS azure Build ng build configuration=production not working

我们已经升级到 Angular 6,所以我们必须将 ng build env=prod 更改为 ng build configuration=production 因为 angular-cli.json 不再被使用。

在本地,ng build configuration=production 工作正常,我在产品中需要的设置也在那里。但是当我们在 azure VSTS 中触发构建 step/task 时,ng build configuration=production 不会将开发设置替换为生产。

有人遇到过吗?你们做了什么来解决这个问题?

首先,尝试将语法更改为

ng run [project]:build:production

其中 [project] 替换为在 angular.json 中的项目对象中指定的项目名称。

例如,如果您的项目名为"my-app",则尝试

ng run my-app:build:production

其次,在 angular.json 中,确保 my-app > architect > build > configurations > production 按照您期望的方式定义。

第三,注意构建的输出将是 dist\[project]\production(假设你的 "outputPath" 是 "dist")。您需要确保您的 VSTS 构建的工件包含这些文件(例如,通过将它们存档到 ZIP 中,然后将它们复制到 $(Build.ArtifactStagingDirectory))。