MonoGame Kickstarter

I can look into template creation but for it to work I guess I will have to make the dotnet tool work with the simpler templates first. In this case the mgdesktopgl and mgwindowsdx templates work but the mgandroid does not.

Is the import declaration correct? Or is my system setup / configuration not correct? Or what is the problem?

It is simply not possible at the moment to work with Xamarin.Android projects from the dotnet CLI until .NET 6 will be out in November 2021. See comments / discussion on GitHub https://github.com/MonoGame/MonoGame/issues/7350

So for MonoGame Kickstarter this means that while the mgdesktopgl and mgwindowsdx projects can be setup automatically by the script and everything just works for Android you would have to do some steps by hand.

Using e.g. Visual Studio 2019 the additional steps after running the MonoGame Kickstarter script (with Android project generation enabled to have it generate the project template) are:

  1. Open the solution and add the Android project
  2. Add a reference to the Android project to the NetStandardLibrary project
  3. Inside Visual Studio delete or exclude the Game1.cs from the Android project (it should be marked as not found already because it was deleted already on disk by the script)
  4. Right click the Android project and select Set as Startup Project from the context menu.
  5. Add to line 68 in the android.csproj an entry for the content from the NetStandardLibrary project so the shared content is available (replace SOLUTIONNAME !!!).
<ItemGroup>
  <MonoGameContentReference Include="..\SOLUTIONNAME.NetStandardLibrary\Content\Content.mgcb" Visible="false" />
</ItemGroup>

This way the Android project has content available from the shared content mgcb from the NetStandardLibrary project and also the default content which the template provides for Android projects.

I pushed everything to GitHub to the android branch if yomebody wants to test it. The script will also output the info about how to do the manual steps.

At this point the manual steps are not tested very much. I will test it if I have more time.

The mid term goal was to automate the setup of at least the project types mgdesktopgl and mgwindowsdx which MonoGame Kickstarter can provide. To have the mgandroid project to be included as well would have been nice but as described that is not available via the dotnet CLI yet until it will be supported by .NET 6 in November 2021. At least with some manual steps the remaining setup steps for an optional Android project can be done with Visual Studio 2019 as described.

As suggested there is also the alternative to the MonoGame Kickstarter script of creating a dotnet template. This way the automated setup of all projects should be possible if someone wants to create their own solution.

Interesting project. Does it target MG 3.8 or 3.7?

1 Like

Thank you, I hope the project is of some use for the community.

To answer your question the script is using the locally installed MonoGame templates. So it is using 3.8 or newer depending what is installed.

To install / update the dotnet CLI templates you only need one command

dotnet new --install MonoGame.Templates.CSharp

MonoGame Kickstarter checks at some point if the MonoGame templates are installed since they are required and prints the command if none are found.

The command is from the official MonoGame documentation.

Since MonoGame Kickstarter is at the core only just using the dotnet CLI you can modify and add or remove anything you want later from the generated solution and / or projects.

1 Like

Looking into this again. I would like to add automatically generated Android projects! They can be generated already but there are manual steps necessary after project creation. So what I want to add is the scripted version of the manual steps needed to get a visual studio solution with everything just working from the start (shared code and content through a net standard library project, a windows dx, opengl / desktop project and an android project.

One of the steps is to manually add the existing Android project to the solution. I looked into what is different after adding the project to the solution and it isnā€™t of course just a line somewhere, it is a lot of stuff. And I donā€™t really know how the internals work and would prefer a somewhat robust way of adding the project to the solution. Anybody here knows how I could achieve this through bash scripting?

Normally the dotnet cli command with sln add would do it (like for the other project types). But for Android it does not work as described in the thread.

Second option which I thought about for a moment was just using visual studio from the command line and add the project this way. But this would rely on visual studio and would complicate everything even more and I donā€™t think it is reasonable to follow that path.

New Demo video for MonoGame Kickstarter

At the moment it supports creating DesktopGL, WindowsDX and Android (more or less meaning manually adding the project to the visual studio solution is necessary after the script has finished).
I need to fix some things first before I want to update the git repo. Of course you can check the bash script out and edit and or replace things however you like to make it work for you.

GitHub repo is updated (see first post in this thread for the link to the repo).

Steps to quickly test MonoGame Kickstarter:

  1. Check out the repository
  2. Install git for windows (if you donā€™t have it)
  3. Open git bash and navigate to the repository folder
  4. run the command ./monogame-kickstarter.sh -owa MyMonoGameKickstarterGame
  5. Inside Visual Studio manually add the Android project to the solution by right clicking the solution and by clicking add existing project

So the script is still completely pointless - especially now that monogameā€™s dotnet templates are a thing.

Where can I find the template?

dotnet new -i "MonoGame.Templates.CSharp"

Thatā€™s not what I need. I hope that eventually there will be a collection of templates available which do what the script is doing so I donā€™t need the script anymore.

What I would like to have is a template which creates 4 projects android, windowsdx, desktopgl, net standard class library for the shared code and content and a visual studio solution. I just donā€™t like to run all comands and edit the csproj files and do a lot of manual steps in vs for new projects.
Is something like this available somewhere?

Do you create new crossplatform projects THIS often?

yes, I have many old projects and I want to update them