Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

c# - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...