As I understand it, a Custom Game Server executable is run in a subfolder.
How can I get the path to this subfolder? So that my exe can know where to look for configuration files.
As I understand it, a Custom Game Server executable is run in a subfolder.
How can I get the path to this subfolder? So that my exe can know where to look for configuration files.
All the files in your Zip are decompressed in-place to one folder, so that all the files are exactly where you put them. So if you have config files in the same folder with the exe, you can just reference them via ".\config.file". Alternately, depending on your implementation language, you could use Application.ExecutablePath.
Currently my exe uses an App.config file with a line: <probing privatePath="Lib;Plugins" />
This lets my exe search in the Lib/ and Plugins/ folders for dlls.
Would I just want to add a ".\" before the paths? That would be a bit annoying having a different config file for the server vs. local, but if it has to be done, it has to be done.
Edit: Also, how can I get the exe to load the Server.exe.config XML file in the first place?
Actually, all I meant was that you cannot use an absolute path in your code for those, since you don't have any way to guarantee what folder your Zip is decompressed into - it could change, potentially. Most libraries that use external configuration files, DLLs, etc. use relative paths to get to them, which would work fine. The only absolute paths you should be using are the ones passed into the server in the command line. In fact, if your server were using an absolute path for either Lib or Plugins in your example, adding ".\" in front of it wouldn't help - the resultant path would be incorrect.
Thanks - I ended up just doing two things to hopefully solve this.
1) using Costura.Fody to embed the dlls into the exe directly, so I don't require any config files
2) using Directory.SetCurrentDirectory() to set the current directory to one-directory-up ("..\") and using Directory.GetCurrentDirectory() in the server code to infer the relative paths of the dlls.
1 Person is following this question.