Service Fabric include additional files

…衆ロ難τιáo~ 提交于 2019-11-29 13:16:27

In order to encapsulate this behavior into the Service project itself, you could edit the service's project file to include MSBuild logic which dynamically includes <Content> items to the project that have CopyToOutputDirectory set to Always or PreserveNewest. These items would be dynamically included at build time based on the configuration of your DI. Since the service project is "declaring" that it has these content items, they will be copied to the service's package folder.

Another option is to add logic at the Application project during the Package step. You can implement a target there like this:

<Target Name="AfterPackage" AfterTargets="Package">
  <!-- Copy dependency files to service package location -->
</Target>

Your logic there would do the same type of reading of your DI configuration but, rather than adding <Content> items, it would simply copy the files to the appropriate location within the application package whose path is defined by $(PackageLocation).

Using Matt's suggestion above, I got this to work in my sfproj to copy some native dlls required by my application. Just in case anyone has this same use case:

<Target Name="AfterPackage" AfterTargets="Package">
    <Copy SourceFiles="ApplicationPackageRoot\mynative.dll" DestinationFolder="$(PackageLocation)\MyServicePkg\Code"/>
  </Target>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!