Skip to content

macOS build reports ModUtils.Environment.CurrentPlatform as Linux and loads Linux C# mod assemblies #283

Description

@Sherdrom

Checklist

  • I searched existing issues for similar reports.
  • This issue occurs while loading a C# mod.

What happened?

On macOS, LuaCs selects C# assembly resources declared with Platform="Linux" instead of the corresponding Platform="OSX" resources.

For a mod that ships normal per-platform assemblies:

<Assembly File="%ModDir%/bin/Client/Linux/TestMod.dll"
          Target="Client"
          Platform="Linux" />
<Assembly File="%ModDir%/bin/Client/OSX/TestMod.dll"
          Target="Client"
          Platform="OSX" />
<Assembly File="%ModDir%/bin/Client/Windows/TestMod.dll"
          Target="Client"
          Platform="Windows" />

the macOS client attempts to load the Linux assembly. If that assembly exposes MonoGame types, package type discovery fails because MonoGame.Framework.Linux.NetStandard is unavailable on macOS.

Expected behavior: the macOS client should select only the Platform="OSX" resource.

Reproduction steps

  1. Run the macOS LuaCs client.
  2. Enable a C# mod containing both Linux and OSX assembly entries as shown above.
  3. Make the Linux assembly reference MonoGame.Framework.Linux.NetStandard and the OSX assembly reference MonoGame.Framework.MacOS.NetStandard.
  4. Start the game and let LuaCs load the package.
  5. Observe that LuaCs attempts to load the Linux assembly.

Removing/commenting the Linux entry prevents the Linux assembly from being selected, but this is only a package-level workaround and breaks proper Linux distribution.

Runtime verification

Reading the fields from the installed macOS Barotrauma.dll produces:

Barotrauma.ModUtils+Environment.CurrentPlatform = Linux
AssemblyInfo.CurrentPlatform = MacOS

This confirms that the base game identifies the platform correctly, while LuaCs reports Linux.

Possible cause

The macOS projects define the OSX compilation symbol:

However, ModUtils.Environment.CurrentPlatform checks MACOS, then falls back to Linux:

#elif MACOS
    Platform.MacOS;
...
#else
    Platform.Linux;
#endif

There are two mismatched names:

  1. The compilation symbol is OSX, not MACOS.
  2. The LuaCs platform enum contains OSX, not MacOS.

PackageManagementService.SelectCompatible then filters resources using this incorrect value:

Relevant error

[CL] FluentResults: Error: Failed to get types from Package 'Vanilla_Components_Expanded'

System.Reflection.ReflectionTypeLoadException:
Unable to load one or more of the requested types.

Could not load file or assembly
'MonoGame.Framework.Linux.NetStandard, Version=3.7.0.0,
Culture=neutral, PublicKeyToken=null'.
The system cannot find the file specified.

Environment

  • OS: macOS 15.7
  • Barotrauma: 1.12.7.0
  • LuaCsForBarotrauma: latest, commit 0d380afcd1feeb842c0c86290d46bcaf198cd5e4
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug / issueSomething isn't working or needs to be addressed.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions