LavaGang / MelonLoader

The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono
https://discord.gg/2Wn3N2P
Apache License 2.0
2.5k stars 479 forks source link

[Enhancement]: Issues running Windows game on Linux with dotnet installed on Linux #740

Open samr7 opened 2 months ago

samr7 commented 2 months ago

Describe the new feature or enhancement

I followed the instructions for how to install MelonLoader v0.6.4 for a Windows game running under Steam Proton on Linux.

I had some problems, and would like to share my solution.

The main problem is that it failed to load hostfxr:

[ERROR] il2cpp_init detour failed: Failed to load hostfxr. Please make sure you have installed the .NET 6.0 runtime.

I definitely had the dotnetdesktop6 package installed per the instructions.

It turned out that it was failing because the Linux dotnet SDK was installed on the host, and it configures a system-wide environment variable, DOTNET_ROOT. This environment variable was being passed into the Proton Windows environment. The Windows dotnet host tool also uses this environment variable, and having it set, especially to a Linux host path, prevented it from finding its runtime.

In Steam, this environment variable can be cleared by setting launch options for the game:

DOTNET_ROOT= %command%

I don't think this should be fixed/enhanced in MelonLoader itself, but maybe it would help somebody else if it got into the instructions.

ZanDev32 commented 1 week ago

@samr7 Can you make a short step by step how to set the environment variable on Lutris or just using winetricks?

samr7 commented 1 week ago

@ZanDev32 Are you also noticing this problem? I am unfamiliar with Lutris. I also don't know of a good way to do this using Wine built-in mechanisms or winetricks. It's possible to set environment variables in user.reg, but setting one to an empty string does not have the effect of removing or masking an existing environment variable.

KibblesTheKitten commented 1 week ago

Simply run the dotnet installer in wine tricks. Make sure you are using the x64 desktop runtime executable! And also add the version library in wine cfg under the libraries page in wine tricks to the prefix