In Service Fabric, can I alter the Arguments in the ServiceManifest.xml file using Application Parameters?

守給你的承諾、 提交于 2019-12-01 11:02:55

Doesn't look like you can do that... Instead, you could try a workaround where you write a small .NET wrapper that reads the sf configuration and then launches your guest executable. You could redirect stdin/stdout from the child process and hook into it's exited event as well so the main process terminates when the child terminates.

Similar to parameters, you can define environment variables (say Prop_AliasesPath andProp_BehavioursPath) in ServiceManifest.xml and then override their values in ApplicationManifest.xml. Then you have two options:

Option 1: Even if your entry point MyProgram.exe is not service fabric aware, it can read the environment variables.

Option 2: To avoid reading environment variables inside MyProgram.exe, you can use a batch file as a entry point and from it call "MyProgram.exe LoadFrom=%Prop_AliasesPath%%Prop_BehavioursPath%"

More info about overriding Environment Variables: https://dzimchuk.net/using-code-package-environment-variables-in-service-fabric/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!