gpt4 book ai didi

webpack - dotnet 发布在预发布完成之前运行

转载 作者:行者123 更新时间:2023-12-02 04:37:15 28 4
gpt4 key购买 nike

我的 dotnet publish命令在执行发布步骤之前不会等待预发布完成。结果是缺少已发布的内容。

在我的场景中,prepublish 运行 webpack 来生成 wwwroot。但是发布发生在预发布完成之前,导致 wwwroot 丢失。如果我再次发布,因为 wwwroot 现在存在,它会正确发布。

这是相关的 project.json 部分

"publishOptions": {
"include": [
"appsettings.json",
"Views",
"web.config",
"wwwroot",
"AppStore/dist"
],
"exclude": [
"wwwroot/dist/*.map"
]
},


"scripts": {
"prepublish": [
"npm install",
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod",
"node node_modules/webpack/bin/webpack.js --env.prod"
],
},

还有人看到这个吗?运行 Dotnet Core 1.0.0-preview2-1-003177

最佳答案

我找到了 this dotnet/cli 上的问题,它描述了您的行为。有一个follow up在 aspnet/websdk 存储库中,它还描述了一个解决方法:

<Target Name="PrepublishScript" AfterTargets="ComputeFilesToPublish">
<!-- Exclude old script and font files from publish output-->
<ItemGroup>
<PrevScriptFiles Include="wwwroot\**" />
<ResolvedFileToPublish Remove="@(PrevScriptFiles->'%(FullPath)')" />
</ItemGroup>

<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />

<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="wwwroot\**" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>

最新的评论显示,这很长时间不需要:

This change is already available in the latest CLI (and should be available in an upcoming VS release).



但无论如何,只是想发布解决方法......

关于webpack - dotnet 发布在预发布完成之前运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41136302/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com