dotnet发布在preublish结束之前运行

时间:2016-12-14 06:39:31

标签: .net webpack publish core

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

在我的场景中,preublish运行webpack以生成wwwroot。但是发布在preublish结束之前发生,导致缺少wwwroot。如果我发布againg,因为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

1 个答案:

答案 0 :(得分:0)

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

<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>

最新评论表明,很长一段时间不需要这样做:

  

此更改已在最新的CLI中提供(并且应在即将发布的VS版本中提供)。

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