I have a Visual Studios solution containing the following:
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.
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>
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With