2016-12-14 43 views
3

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

在我的场景中,preublish运行webpack以生成wwwroot。但是,在发布前完成发布会导致缺少wwwroot。如果我发布againg,由于wwwroot现在存在,它会正确发布。

这里的

"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" 
     ], 
    }, 

任何人看到这个相关project.json部分?运行Dotnet核心1.0.0-preview2-1-003177

+1

现在看到的这个权利,你有没有找到解决的办法? – Max

回答

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版本中提供)。

但无论如何,只是想后的解决办法...