我已经使用 VS 创建了一个 VS 2022 项目开箱即用的 ASP.NET Core 与 React.js 和 Redux 模板。
当我发布项目时,我在输出窗口中看到它使用npm install
命令。
如何修改构建 / 发布过程以使用yarn build
命令而不是npm install
?

在项目的.csproj 文件中,我更改了以下行:
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
收件人:
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="yarn" />
<Exec WorkingDirectory="$(SpaRoot)" Command="yarn build" />
(另外我已经相应地改变了构建过程:)
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
收件人:
<Message Importance="high" Text="Restoring dependencies using 'yarn'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="yarn" />
首先,使用 npm 全局安装 yarn。
npm install --global yarn
yarn --version
安装方法因操作系统而异,具体取决于 Windows 和 Mac。
然后,您可以使用 yarn 运行使用 npm 运行的部门。您可以使用 'yarn start','yarn bulid' 等运行它,而不使用 'run' 如 'npm run start'。
npm run start
如果使用纱线
yarn start
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(24条)