Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Fabric application's root directory

In my code I fail at

if (!File.Exists(_configurationFileName)) {...}

In the immediate window I made a call to Directory.GetCurrentDirectory() and it pointed me to the "work" folder rather than the "code" folder which I would have expected.

Directory.GetCurrentDirectory()
"C:\\SfDevCluster\\Data\\_App\\_Node_0\\My.Application.Type_App2\\work"

So my configuration file which is sitting right next to the executable is of course not being found.

Now I wonder what the solution is.
Since I also want to keep running the console application I don't want to implement any "if service fabric hosting, then change current directory, ..." workaround.

Any recommendations? What about my .exe.config files (if I had any, how would they be found)?

What's the reason for Service Fabric settings the current directory to "work"? Is this some kind of security mechanism?

like image 976
lapsus Avatar asked Sep 27 '16 15:09

lapsus


1 Answers

This is how i just did it change the service manifest to point at the code

<EntryPoint>
  <ExeHost>
    <Program>configui.exe</Program>
    <WorkingFolder>CodePackage</WorkingFolder>
  </ExeHost>
</EntryPoint>
like image 190
user1496062 Avatar answered Dec 22 '22 01:12

user1496062