Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Fabric include additional files

I have a Visual Studios solution containing the following:

  • Service Fabric project
  • Stateless Service Project

The stateless service project uses configuration-based dependency injection, meaning the dependencies are loosly coupled with the project itself and not actual VS "project/compilation dependencies".

I would like to continue to use Visual Studios, but when I deploy this project it doesn't know about the assembly dependencies (as these are only defined in DI configuration) and therefore it doesn't package up the necessary files and throws exceptions trying to perform dependency injection.

Is there any way in the ApplicationManifest.xml file or one of the other many XML files that Visual Studios provides that I can specify additional files (i.e. my dependent assemblies) to be published to Service Fabric as part of the deployment?

Ideally, I'd like to automate this file to be generated as part of my automated build script.

like image 672
tommed Avatar asked May 17 '16 13:05

tommed


2 Answers

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>
like image 57
AdamC Avatar answered Nov 03 '22 18:11

AdamC


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

like image 26
Matt Thalman Avatar answered Nov 03 '22 19:11

Matt Thalman