为什么 Gulp return 在 VSTS 中编码为 255?

Why does Gulp return code 255 in VSTS?

我正在尝试通过托管代理在 Visual Studio 在线构建过程中使用 Node + Gulp。

第一步(节点安装)工作正常,但第二步 returns:

[command]C:\NPM\Modules\gulp.cmd --gulpfile C:\a\s$(build.AgentDirectory)\Platform\gulpfile.js \Platform\gulpfile.js was unexpected at this time.

C:\a\s> "C:\NPM\Modules\node.exe" "C:\NPM\Modules\node_modules\gulp\bin\gulp.js" --gulpfile C:\a\s$(build.AgentDirectory)\Platform\gulpfile.js

[error]Gulp failed with error: C:\NPM\Modules\gulp.cmd failed with return code: 255

我查看了类似的问题,这些问题强调全局安装节点 and/or 确保项目文件中没有空格。既不适用也不似乎有帮助。

最后是我的路径和步骤的配置方式:

  1. NPM 安装(工作文件夹:$/Platform/Platform,命令:安装)
  2. Gulp(Gulp 文件路径:$/Platform/Platform/gulpfile.js,Gulpjs 位置:node_modules/gulp/bin/gulp.js,工作文件夹空白)

设置 Gulp 文件路径似乎是强制性的,因为 Gulp.js 位于存储库的子目录中。所有其他设置似乎都没有太大帮助。

有什么建议吗?

是的,你需要用相对路径指定gulp文件,路径可以是服务器路径(如你所说)和当前工作目录的相对路径(cwd: C:\a\s),例如 CoreAppDemo/src/CoreWebDemo/gulpfile.js

根据gulp构建任务的source code,可以发现它没有解析构建变量,所以无法识别$(build.AgentDirectory)。