运行 npm install 在 Visual Studio 项目的 post-build 事件中

Running npm install in a Visual Studio project's post-build event

在我项目的 post-build 事件中,我有 2 个任务--运行 npm install 然后是 运行 gulpfile。

我正在使用 Azure DevOps 并在我的构建管道中,当 npm install 在我项目的 post-build 事件中是 运行 时,它只会 运行 npm install 命令而不是 gulpfile。它输出:

但是,如果我 运行 一个 npm install 任务(直接指向我的 package.json)在 npm install 之前 运行 在我的项目 post-构建事件,然后 gulpfile 确实得到 运行.

我想知道这里可能有什么问题?是因为我没有在 post-build 事件中指定 package.json 吗?

我的 post-build 事件脚本如下所示:

npm install
node.exe "node_modules\gulp\bin\gulp.js" --gulpfile "gulpfile.js"

问题是在 post-build 事件脚本中直接调用 npm install 会停止父批处理程序。解决此问题的方法是使用命令 call,记录在 here 中。即使用call npm install.