2017-09-01 75 views
0

這裏是我的A.csproj的一部分:DOTNET發佈不包括後生成事件過程中生成的文件

<ItemGroup> 
    <Content Include="..\..\Payloads\**\*.*"> 
     <Link>Payloads\%(RecursiveDir)%(FileName)%(Extension)</Link> 
     <CopyToOutputDirectory>None</CopyToOutputDirectory> 
     <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> 
    </Content> 
    </ItemGroup> 

Payloads目錄是從項目A

B.csproj 

<PropertyGroup> 
    <PostBuildEvent> 
     xcopy /I /S /R /Y /d $(TargetDir)*.* $(SolutionDir)Payloads\Content 
    </PostBuildEvent> 
    </PropertyGroup> 

引用的項目B創建Payloads目錄在我運行時不存在publish目錄中dotnet publish

信息

dotnet SDK version 2.0, ASP.NET Core 2.0 on .NET 461 framework 

好像發佈內容構建之前計算。當我運行dotnet發佈時,如果Payloads存在,它會正確部署。這只是我的項目的簡單例子。 我該如何解決這個問題?

回答

0

我更換

<ItemGroup> 
    <Content Include="..\..\Payloads\**\*.*"> 
     <Link>Payloads\%(RecursiveDir)%(FileName)%(Extension)</Link> 
     <CopyToOutputDirectory>None</CopyToOutputDirectory> 
     <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> 
    </Content> 
    </ItemGroup> 

隨着

<Target Name="AddPayloadsFolder" AfterTargets="AfterPublish"> 
     <PropertyGroup> 
      <PayloadsDirectory>$(SolutionDir)Payloads</PayloadsDirectory> 
     </PropertyGroup> 
     <Exec Command="xcopy.exe /I /S /R /Y /d $(PayloadsDirectory) $(PublishDir)Payloads" Condition="!Exists('$(PublishDir)Payloads')" /> 
     <Exec Command="xcopy.exe /I /S /R /Y /d $(PayloadsDirectory) $(PublishUrl)Payloads" Condition="!Exists('$(PublishUrl)Payloads')" /> 
     </Target> 

與PublishUrl的版本的Visual Studio。它使用它來兼容。