SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

NETSDK1124 - Error when building on MacOS

acovaci opened this issue ยท 3 comments

commented

Describe the bug
Hi, obligatory I'm not used to C#/.NET dev at all :).

I'm trying to build the project on MacOS. The windows build seems to work fine, but for the Linux build I run into the following issue:

Compiling installer for linux...
-------------------------------------------------
MSBuild version 17.9.8+b34f75857 for .NET
  Determining projects to restore...
/usr/local/share/dotnet/sdk/8.0.204/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1124: Trimming assemblies requires .NET Core 3.0 or higher. [/Users/######/Documents/Projects/SMAPI/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj::TargetFramework=netstandard2.0]
/usr/local/share/dotnet/sdk/8.0.204/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1124: Trimming assemblies requires .NET Core 3.0 or higher. [/Users/######/Documents/Projects/SMAPI/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj::TargetFramework=netstandard2.0]

To Reproduce

  1. Fresh clone of the repo
  2. Set the game path in build/unix/prepare-install-packages.sh in the $gamePath variable
  3. ./build/unix/prepare-install-packages.sh

What I tried so far

I tried changing the TargetFramework to core3.0, but ran into new errors.

Does anyone have a working reproducible setup to build for MacOS? Thanks

commented

Okay so while waiting for a reply from people more knowledgable than me, after a bit of googling, I found out I can create a global.json in the root with:

{
    "sdk": {
        "version": "6.0.100",
        "rollForward": "patch"
    }
}

Now the error disappears, but I'm running into a whole new issue:

/Users/######/Documents/Projects/SMAPI/src/SMAPI/Framework/Logging/VerboseLogStringHandler.cs(24,16): error CS0171: Field 'VerboseLogStringHandler.Handler' must be fully assigned before control is returned to the caller [/Users/######/Documents/Projects/SMAPI/src/SMAPI/SMAPI.csproj]

I tried with both 6.0.1xx and 6.0.4xx with no luck. Meanwhile, 6.0.0 has no M1-compatible SDK.

commented

Okay so now I am able to debug, but running into this:

/Users/######/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/StardewModdingAPI 
Failed to load /Users/######/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/libhostfxr.dylib, error: dlopen(/Users/######/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/libhostfxr.dylib, 0x0001): tried: '/Users/######/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/######/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/libhostfxr.dylib' (no such file), '/Users/######/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
The library libhostfxr.dylib was found, but loading it from /Users/######/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/libhostfxr.dylib failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=2063366

EDIT: Just to clarify, this is now using Visual Studio for Mac, and .NET 6.0

commented

Hi! This should be fixed with SMAPI 4.1.0; let me know if you still have issues building it on Linux/macOS now.