(MacOS) How do I hot reload a C# project dll that is being used in a different app?
Hi guys, I'm making a mod for Stardew Valley using Rider on MacOS (M2 Pro). These mods are loaded as DLLs by the Stardew Valley executable. The VS Code/VS for Mac debuggers are bugged on arm64 so they don't even attach to the executable. However, attach to process works on Rider so I'm using that. The hot reload feature doesn't work. I wanted to see if dotnet watch works but it seems that hot reload only works on the 'dotnet watch run' command. However you cannot specify different watch and run targets for the command. So, in essence, you would need to have the game as your project but that's absurd because we don't have the game code. Is there a workaround I'm missing?
7 Replies
if you are attached with a debugger, you cannot use hot reload on a mac, unless the program is using .NET 8 or later (as far as I can tell SV mods run on .NET 6, so, that's a no-go)
as for
dotnet watch
, let me look at the code, it seems like it should be possible in principlehere's the code: https://github.com/arannya/Farmtronics/tree/unofficial
and I don't need debugging/breakpoints when i want to hot reload
GitHub
GitHub - arannya/Farmtronics at unofficial
My fork of a Stardew Valley mod that adds a Home Computer and Bots to the game - GitHub - arannya/Farmtronics at unofficial
i mean, i'm about to look at the code for dotnet-watch to see how it should be done
oh sorry my bad
and yes SV mods target .NET 6.0
I'm okay with hot reload only
ok, so, it's pretty clear that there's no way to work around the fact that it's only enabled with
dotnet watch run
i am trying to figure out how exactly it launches the program, maybe there's some way to get it to launch the game instead
yes, yes you can
RunCommand, RunArguments, RunWorkingDirectory
these are the project properties that dotnet run
uses to get the program to actually start
so, you can set them in your project to be whatever program actually starts the game
then, dotnet run
will start the game. and so, dotnet watch run
will also start the game and attach hot reload to itOhh great ill try this. Thank you!
I got it working @reflectronic , you have been a godsend! I can't thank you enough
awesome, glad that it's working!