MGFX effect was built for a different platform! and 3.8 [Solution]

I have just suffered the dreaded MGFX effect was built for a different platform! error while using a shared library project along with a WindowsDX app project. None of the solutions I found on this site solved this issue so I wanted to post my solution here for the benefit of others.

It’s pretty common to use a shared library project to hold your code and content for your cross-platform game and then have an app project for each platform you want to release onto. However out-of-the box you will get the error while loading an effect and this is because the effect compiler is platform-specific so you cannot allow the shared library project to build the content.

The key to solving the error is:

  • Remove the MonoGame.Content.Builder.Task nuget package from the shared library project.
  • Remove the Content folder from the app projects.
  • Hack the app projects .csproj files to reference the Contents folder in the shared library, by adding this ItemGroup tag:
  <MonoGameContentReference Include="..\SharedLibraryProject\Content\Content.mgcb" />

This should solve your problems. I have tested this with WindowsDX and DesktopGL app projects.

1 Like

Nice share, I amended your title to include [Solution] otherwise it looks like a request for support…

1 Like