Debugging Dedicated Server - Vriable Optimized Away

So I got a dedicated server to debug in VS2015 by packaging a GameServer.exe, added the Object files for debugging symbols to where GameServer.exe is, and in Visual Studio pointed the Target Path to where GameServer.exe is. I then changed the Solution Configuration to “DebugGame Editor”, but even though I can put breakpoints when debugging dedicated server, the local variables are still optimized away.

How do I properly setup Dedicated Server debugging so that I can view variables and put breakpoints in properly?

Thanks

Even if you run the editor in Debug mode, the binary for the server (exe) has to be built with Debug (without optimizations). Otherwise variables may be scrapped in the server code, regardless of what config you select for the editor, and no amount of debug information can do anything about it (debug info is only relevant to the code in the exe, but if variables have been optimized away, like intermediate values and such, and are not present in the exe, debug info cannot reference them).
Hope this helps.

So how do you build the binary for the server exe file with debug mode then? I just chose “development server” configuration when I wanted to generate GameServer.exe, do I have to to use “DebugGame Server” configuration to generate it instead?

Yep, I think it’s either DebugGame Server or just Debug Server (I forgot the exact difference between the two)

The debug builds will get you most of the way, but there are still some optimisations left on so some variables will be optimised out. To build a module fully debug you need to edit the Build.cs for the module and add:
OptimizeCode=CodeOptimization.Never

This should help: