Building iOS project on MG 3.8.1 - cannot restore NuGet packages (and other issues)

Hi folks,

I’m trying to configure a MonoGame 3.8.1 environment on Mac, so far without success. After installing Visual Studio for Mac (17,4), I’ve tried a number of IDE and CLI scenarios to create and build an iOS project.

IDE

  • Installed extension 3.8.1.303 using IDE. Completed with warning: “The add-in ‘MonoGame.Templates.VSMacExtension,3.8.1.303’ could not be updated because some of its dependencies are missing or not compatible: required MonoDevelop.Core,17.0.6, found: MonoDevelop.Core,17.4.3 required MonoDevelop.Ide,17.0.6, found: MonoDevelop.Ide,17.4.3”.
  • Created a new MonoGame iOS app project.
  • Build failed with error: “NuGet packages need to be restored before building. NuGet MSBuild targets are missing and are needed for building. The NuGet MSBuild targets are generated when the NuGet packages are restored.”
  • NuGet restore failed with error: “MSB4019: The imported project “/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/16.0.1478/targets/Xamarin.Shared.Sdk.MultiTarget.targets” was not found. Confirm that the expression in the Import declaration “;…/16.0.1478/targets/Xamarin.Shared.Sdk.MultiTarget.targets” is correct, and that the file exists on disk.
    Unable to create package spec for project.”

CLI

  • Installed extension via CLI using “dotnet new install MonoGame.Templates.CSharp”. Completed with error: “Error: Failed to load template from /Users/chrish/.templateengine/packages/MonoGame.Templates.CSharp.3.8.1.303.nupkg(/content/content/MonoGame.Application.UWP.CoreApp.CSharp/.template.config/template.json): Missing ‘identity’.”
  • Created app with “dotnet new mgios -o appname”. Build failed with error: “NETSDK1147: To build this project, the following workloads must be installed: ios”
  • Ran “dotnet workload restore” to install workloads. Failed with error: “InvalidProjectFileException: The imported project /usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.Sdk/16.0.1478/targets/Xamarin.Shared.Sdk.MultiTarget.targets was not found. Confirm that the expression in the Import declaration ;…/16.0.1478/targets/Xamarin.Shared.Sdk.MultiTarget.targets” is correct, and that the file exists on disk."

Environment:

  • macOS Monterey 12.6.2
  • 2.6 GHz 6-Core Intel Core i7
  • Xcode 14.2 (latest)
  • Visual Studio for Mac 17.4 (latest)

I’ve looked at a bunch of issues in the forums regarding individual steps in these scenarios, but it’s unclear if there’s currently a reliable end-to-end Mac installation process. Has anyone faced and overcome these issues recently? My previous environment based on older VS and MG versions is no longer intact, so I’m really hoping to find a way through. Appreciate any advice anyone can provide.

1 Like

Hey I have had success creating an OpenGL (Desktop) targeted game in MonoGame on an M1 Mac. It sounds like that might not fit your use case but in case it helps these are a couple threads I posted with solutions that worked for me:

  1. I couldn’t get my project to compile with textures in Visual Studio, turns out it’s because on an M1 Mac you need to change your .net dependencies to x64 manually. Full thread here.

  2. I couldn’t get .fx files to compile on my Mac either. Turned out I needed to compile them directly using MGFXC (described in docs) and also update a file name that is no longer correctly described in the docs to install Wine properly. Full thread here.

Again, not sure if those fit your situation and I don’t have the technical knowledge to help directly, but wanted to share those in case there are tidbits that lend some insight.

Oh and I had to build my project via CLI before opening in VS for Mac in order to get setup initially.

1 Like

@groll Appreciate the info. Mac seems to be a bit of a minefield, so good to know some of the issues I might hit along the way.

Finally worked out that I had to use sudo to install the ios workload.

Resolution steps are:

  • Follow the CLI steps as described in the original post
  • Run sudo dotnet workload install ios
  • Make sure minimum OS version in the csproj file and Info.plist are the same
  • VS for Mac can now be used to build and run the project.
1 Like