Some pointers migrating from 3.7 to 3.8 references and shared projects multiple platforms

Well this is a list of problems i have encountered and how i solved them. Maybe all of this is obvious but it might help someone staring out. If nothing else i documented this for me.

Feel free to criticise, banter or mock my solutions :slight_smile:

Problem:
Visual Studio 2019 likes to report nuget warnings. Yellow triangles on the monogame packages. At best everything works fine and at worst your autocomplete stops working or you cant build your project.

It gets alot worse with shared projects or if you have a lot of references.

Solution:
Restart your solution or drop and reload the project.

Problem:
Some of the templates don’t have any Conditional compilation symbol. So if you do some #if in your project it will fail to use them.

Solution:
In the preferences of your project in the Build tab you can add them.
For example the OpenGL use to have LINUX in 3.7 you can add more separated by ;
Like so IOS;MOBILE

Problem:
You can’t build because you are missing external dependencies.

Solution:
Open project file and add CopyLocalLockFileAssemblies = true:

like so:

<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

Problem:
Referens libraries to an Android project gives error:
The type or namespace name ‘AndroidGameActivity’ could not be found (are you missing a using directive or an assembly reference?)

Solution:
In the library project make sure your Monogame PackageReference is correct:

This is wrong and will not work trying to reference file in Android project:

<ItemGroup>
        <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" /></ItemGroup>

This is the Correct way and will work:

<ItemGroup>
	<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641">
		<PrivateAssets>All</PrivateAssets>
	</PackageReference>
</ItemGroup>

Problem:
Content folder not found error when using a Shared project on Android if you delete the content folder in the project.

Solution:
The references in the Android project file are still there. you have to manually delete it. Open the project file and delete the following lines:

<ItemGroup>
    <MonoGameContentReference Include="Content\Content.mgcb" Visible="false" />
  </ItemGroup>

Problem:
Using FreeImage in a pipeline to manipulate image files on build fails.

Solution:
Well none… but i rebuilt it in ImageSharp and that works. More info here Pipeline extension 3.8 Unable to load DLL 'FreeImage'

Problem:
You cannot reference .netcore 3.1 projects in to Android project.

Solution:
Make sure you make all projects .netstandard 2.0 that needs to be referenced in multiple platforms.

8 Likes

Nice FAQ, will talk to the team about adding it to the official docs after review.

Although my best advice is to always create a new 3.8 project and simply migrate code / content to the new solution, where possible. Saves a lot of time and hassle. But recognizing, some projects might not be able to do that.

2 Likes

Thank you.

I agree, making new projects and moving the code over is the way to go. These problems where encountered doing just that.

I am just an hobbyist so this list might be something weird I’m doing wrong and have nothing to do with monogame. But i figuerd i might not be the only hobbyist making mistakes :slight_smile:

1 Like