pardeike / Rimworld-Doorstop

A Doorstop.dll implementation that also patches mod loading to improve debugging
4 stars 0 forks source link

Hot reloading? #1

Open ilyvion opened 2 months ago

ilyvion commented 2 months ago

I don't quite understand how hot reloading is meant to work. The instructions say

Any change to a dll inside Mods will create copies of that file and they will be patched in to replace the current version.

But dotnet build refuses to overwrite the dll:

C:\Program Files\dotnet\sdk\6.0.201\Microsoft.Common.CurrentVersion.targets(4631,5): warning MSB3026: Could not copy "obj\Debug\RealisticOrbitalTrade.dll" to "../1.5/Assemblies\RealisticOrbitalTrade.dll". Beginning retry 1 in 1000ms. The requested operation cannot be performed on a file with a user-mapped section open. : 'C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RealisticOrbitalTrade\1.5\Assemblies\RealisticOrbitalTrade.dll' [C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RealisticOrbitalTrade.vscode\mod.csproj]

pardeike commented 2 months ago

Hi, the trick is that you need either the right way to copy the dll’s or be Admin. You can check out my project setup, it works flawless:https://github.com/pardeike/CameraPlus/Andreas PardeikeOn 27 Apr 2024, at 11:41, Alexander Krivács Schrøder @.***> wrote: I don't quite understand how hot reloading is meant to work. The instructions say

Any change to a dll inside Mods will create copies of that file and they will be patched in to replace the current version.

But dotnet build refuses to overwrite the dll:

C:\Program Files\dotnet\sdk\6.0.201\Microsoft.Common.CurrentVersion.targets(4631,5): warning MSB3026: Could not copy "obj\Debug\RealisticOrbitalTrade.dll" to "../1.5/Assemblies\RealisticOrbitalTrade.dll". Beginning retry 1 in 1000ms. The requested operation cannot be performed on a file with a user-mapped section open. : 'C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RealisticOrbitalTrade\1.5\Assemblies\RealisticOrbitalTrade.dll' [C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RealisticOrbitalTrade.vscode\mod.csproj]

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

ilyvion commented 1 month ago

Sorry for being a bit slow to get back to you. I don't really see how your project setup explains anything; I too build my mod using dotnet build and there's nothing else in there that explains hot reloading as far as I can see.

Regardless of whether I try to have it directly overwrite the dll (i.e. I set the OutputPath in the csproj to Mods[Mod]\1.5\Assemblies`) or I build to somewhere else first and then try to copy, I get an error if Rimworld is running at the same time, and the error message is always the same:

The requested operation cannot be performed on a file with a user-mapped section open.

Running VSC/dotnet as an admin seems to make no discernable difference.

This is really frustrating; having to restart the game every time I make a GUI rendering change is getting very old.

pardeike commented 1 month ago

Not sure what you are doing. Have you tried to clone and test-run one of my mod projects?

Sorry for being a bit slow to get back to you. I don't really see how your project setup explains anything; I too build my mod using dotnet build and there's nothing else in there that explains hot reloading as far as I can see.

Regardless of whether I try to have it directly overwrite the dll (i.e. I set the OutputPath in the csproj to Mods[Mod]\1.5\Assemblies`) or I build to somewhere else first and then try to copy, I get an error if Rimworld is running at the same time, and the error message is always the same:


The requested operation cannot be performed on a file with a user-mapped section open.
ilyvion commented 1 month ago

I have not, but I truly can't imagine it would be different. I have tried all kinds of various approaches, like setting <OutputPath> directly to Mods[Mod]\1.5\Assemblies, or building first and then copying over, both in a build script and "by hand," both as an admin and as a regular user, and I'd always get that error message.

But it's okay, I found a different solution that works for me. (Zetrith's HotSwap) Whatever it does differently, it does not appear to make any "user-mapped sections open" in my dll.

Since I'm satisfied with that solution, I don't really wish to spend much more time or effort on solving this, so you may close this issue if you think it's not worth pursuing further without me; it seems nobody else have come by to report it after all.