CityWebServer icon indicating copy to clipboard operation
CityWebServer copied to clipboard

Not auto reloading

Open RenaKunisaki opened this issue 6 years ago • 6 comments

I've been able to build and use the mod from source on Linux, but the game doesn't reload it. I have to exit and restart the game every time I make a change. Any ideas?

RenaKunisaki avatar Apr 04 '19 16:04 RenaKunisaki

I've always compiled the assembly from Visual Studio and relied on a post-build script in the project to deploy the assemblies to the mod directory. This script however, is unique to Windows.

I believe you can press F7 in-game to view the debug panel, which should show the log messages from the server as it is initialized/released. I'd be interested in knowing if changes to the source files are actually triggering the game to take any action, such as even stopping/starting the server.

Rychard avatar Apr 05 '19 04:04 Rychard

I think the C# assembly is probably not being reloaded unless the game is restarted (like if plugins were initialized only once at application load time, which make sense from a software implementation point of view), but all web resources (css/html/js) could be changed and reloaded as the user/developer want. However it's been a long time I did not touch mod code, and I might be wrong regarding assembly load mechanism.

MrSlurp avatar Apr 05 '19 04:04 MrSlurp

The logs suggest the server isn't being stopped/restarted at all.

RenaKunisaki avatar Apr 05 '19 17:04 RenaKunisaki

Well, I found that I can use FileSystemWatcher to know when my DLL gets replaced, and PluginManager.instance.ForcePluginsChanged() to force a reload. But it doesn't actually reload the file, just stops and starts the plugins, so the server restarts but is still using the old version. (Also, some mods throw errors and/or crash the game when doing this...)

Any idea the correct way to reload a plugin from disk? Ideally without forcing reload of all other plugins?

No idea why the game doesn't do it automatically. Maybe it's just not supported on Linux for some reason.

RenaKunisaki avatar Apr 06 '19 20:04 RenaKunisaki

I did some reserch and it seems the there is some mod config per-requisites to allow live reload. Page 6 of https://buildmedia.readthedocs.org/media/pdf/citiesskylinesmoddingguide/latest/citiesskylinesmoddingguide.pdf " To make the game reload your mod while running, change the last two lines in AssemblyInfo.cs to read:[assembly: AssemblyVersion("1.0.*")] "

MrSlurp avatar Apr 10 '19 14:04 MrSlurp

Right, I've done that, still no effect. I tried changing to "2.0.*" as well.

RenaKunisaki avatar Apr 10 '19 18:04 RenaKunisaki