Nuget package for shared library in 3.8?

I am pretty new to C#, but not Visual Studio, and I wonder if anyone can tell me how I reference the MonoGame.Framework nuget package from a shared library? The shared library would be used to share code amongst projects targeting different platforms.

Is it MonoGame.Framework.Portable?

Nevermind - it looks like I used the wrong project template to create my library. If I use the MonoGame shared library template then it references MonoGame.Framework.DesktopGL.

As an aside, I notice this library project contains a Content folder with a Content.mgcb. Does that mean I can package common content using this?

Since there is a ContentManager in the Game1 class of the project that is built then sure, you can use it for shared content.

1 Like

That’s excellent! Forgive my ignorance, but what does this look like during deployment? I know that the Content folder will be copied to the target directory, so is the Content of both the app and the shared library put into the same directory? There is no “bundle” concept is there, like with macOS/iOS?

It will be placed in the Content folder of your game.

1 Like

Great stuff. Thanks for your help!

You can also try MonoGame Kickstarter if you like. Using one command it will setup a solution for Visual Studio and setup one or ore projects (windows directx, opengl crossplatform) together with a project for your shared code and content.
You can then add or remove more projects if you like, it just does automates the manual steps for you.

Here is a video of it showing the command and starting the generated MonoGame project (again you can open it with visual studio also etc).

You can find more information in this thread here

and on the GitHub page


OK, nice. Thanks!

1 Like

If you need support just let me know. I think it may look complicated but it really is not. Basically you would just download the script ( file. Make it executable. Run it providing only a solution name as parameter. Hit Enter and everything should be in a folder named like the solution name in a short time like you see in the demo video.

To run the script you need either run it in bash (linux) or git bash (windows). On the YouTube channel you find another video with a linux demo too…

1 Like

Hey sorry to bother you again. I have a skeleton version of my library working with an effect file (.fx) in the shared library Content, and this effect file is being compiled into shared library output folder Content/bin/DesktopGL/Content.

However the main executable is a UWP app with it’s own Content and the shared library Content does not appear in the AppX target directory. I assume I need a post-build step to copy the library Contents over? Have you had this working yourself in the past?

I’ve had it working in the past, tested this morning to be sure it was copied over. Is this project shared between multiple games?

No it’s a single game app and a single library. Are you using a UWP app?

For the time being I have moved all content into the app and made the ContentsManager available to the library and that will be good enough, at least for now.

Just tested in a UWP app and it is copied for me there as well. Are you running MG 3.7.1 or 3.8? I’ve been testing in 3.8.

@Synammon I am using 3.8. Weird. I did have to add the MonoGame.Content.Pipeline.Task to the shared library in order for it to process the Content.mgcb in the first place, but after that the directory was appearing the target dir of the shared library, just not in the target dir of the app.

I wonder if I’m missing a reference of some sort from the app to the shared library? All I did to start using the library was to right-click the app project and do Reference > Add.

Hello, this might be related to your most recent issue?

1 Like

I did not have to add MonoGame.Content.Pipeline.Task to my shared library. It just built out of the box. That might be part of the problem. Maybe there is something wrong with the template.

1 Like