Creating a cross platform project

So I wrote this a month ago to reference off of whenever I would want to create new shared projects. Hope it’s useful for you:

HOW TO CREATE SHARED PROJECT
“Monogame Shared Library Project”, “Shared Library Project”, and “Shared Project” may be used interchangeably at times.

  1. [If you have already created a new “Shared Library Project”, skip to step 4]

  2. Select “File > New > Project” .

  3. Select “Monogame Shared Library Project”. Ensure you keep the checkbox “Place solution and project in the same directory” unchecked.

  4. Right-click the solution, then select “Add > New Project”.

  5. Select whichever platform specific project you wish to start with. I began with the OpenGL version first.

  6. When you add a project, it will automatically add a “Game1.cs” to that project. We only need the “Game1.cs” from the “Shared Project”. So for each platform specific project, delete each newly created “Game1.cs”.

  7. Everything I said for step 6, do the same thing with the “Content” folders for each of the platform specific projects.

  8. For each of these platform specific projects added, we will need to add a reference to the “Shared Project”. Right-click on the platform specific project, then select “Add > Shared Project Reference”.

  9. Select the name for the “Shared Project” and click “Ok”.

  10. Right-click the “Shared Project”, then select “Open Folder in File Explorer”.

  11. After the file explorer opens, open the file with extension “.projitems” in a text editor.

  12. After this file opens, scroll down until you find a line(s) that may say both or either of the following:

< MonoGameContentReference Include=“$(MSBuildThisFileDirectory)Content\Content.mgcb” />

< None Include=“$(MSBuildThisFileDirectory)Content\Content.mgcb” />

  1. As long as the “MonoGameContentReference Include” line is there, you can close out. Otherwise, just add it within the “ItemGroup” section (“< ItemGroup >your stuff< /ItemGroup >” ).
3 Likes