如何使用 yarn 在 vsts 中创建反应构建管道。找不到 package.json

How to create a react build pipeline in vsts with yarn. Couldn't find a package.json

我有一个 React 项目,在本地我只使用 yarn install、yarn build 和 yarn start 在 https://localhost:3000

测试它

我有以下管道:

但是我在日志中有这个错误:

2018-08-10T08:31:34.6206910Z ##[section]Starting: Yarn build
2018-08-10T08:31:34.6211162Z ==============================================================================
2018-08-10T08:31:34.6211307Z Task         : Yarn task
2018-08-10T08:31:34.6211411Z Description  : Executes Yarn
2018-08-10T08:31:34.6211531Z Version      : 2.5.999
2018-08-10T08:31:34.6211633Z Author       : Geek Learning
2018-08-10T08:31:34.6211842Z Help         : [More Information](https://github.com/geeklearningio/gl-vsts-tasks-yarn/wiki/Yarn) (Version 2.5.999).

Dear Angular and Ember CLI users, please check our [known issues](https://github.com/geeklearningio/gl-vsts-tasks-yarn/wiki/Known-Issues)
2018-08-10T08:31:34.6212057Z ==============================================================================
2018-08-10T08:31:35.2261051Z [command]C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\yarn.9.4\x64\yarn-v1.9.4\bin\yarn.cmd build"
2018-08-10T08:31:42.0864621Z yarn run v1.9.4
2018-08-10T08:31:42.1571684Z error Couldn't find a package.json file in "C:\"
2018-08-10T08:31:42.1572901Z info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2018-08-10T08:31:42.1822978Z ##[error]Error: C:\hostedtoolcache\windows\yarn.9.4\x64\yarn-v1.9.4\bin\yarn.cmd failed with return code: 1
2018-08-10T08:31:42.1893252Z ##[section]Finishing: Yarn build

但实际上有一个package.json

抱歉,您正在为此苦苦挣扎。在您的情况下,您应该将路径留空,它默认为源存储库。

我所做的是存档构建的结果

然后从发布管道中获取该 zip 文件:

不确定这是否是最佳做法,但它对我有用。