2016-12-14 94 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版本中提供)。

但無論如何,只是想後的解決辦法...

相關問題