How to create a library engine project in vs2019?

Hi, i am to monogame i want to create a engine but i can’t find portable class library and monogame does not support .net standard ( i think )

There is a “Monogame Shared Project” solution, though I have never managed to get it to work.

Anyone else tried?

Create new solution which contains shared project and project for platform you want use (win, android…), and from there add reference to shared project.

1 Like

Yes, tried that.

Doesn’t work.

You get errors around .Net and target frameworks not being compatible

That is how you’re supposed to do it. Be more specific about the errors, what they say and where they show up

EDIT: Based on the vague description it sounds like you picked the wrong TargetFramework for your project

Create a new .NET standard 2.0 library and then just add reference to the MonoGame nuget package. I use the DesktopGL.Core package, I would assume you can use a .NET Framework package instead, but it really doesn’t matter since your library itself can’t be used without some other app referencing it.

Open your project file and change the <PackageReference> entry to include the PrivateAssets="All" attribute.

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

This essentially doesn’t include a specific MonoGame reference in your compiled library. When someone uses your library they will decide which MonoGame library to reference and add that MonoGame nuget package to their project.

1 Like