MonoGame.Kickstarter is a bash script that sets up a MonoGame solution ready for cross-platform development. It makes use of the official MonoGame NetStandard Library and MonoGame Cross-Platform Desktop Application (OpenGL) templates and wires everything up, so that the MonoGame Cross-Platform Desktop Application (OpenGL) uses the code and content provided by the MonoGame NetStandard Library project. It is possible to add more project templates later at any time and to include them to the solution by using the .NET Core CLI or from the official templates installed in your favorite IDE like Visual Studio or Rider.
After the script has done its work, you can open the solution with Visual Studio and everything should work as if the solution was setup with Visual Studio itself.
The script was tested with bash on Linux and git bash on Windows.
If you decided to try the script you’re welcome to leave feedback here or on GitHub. Check it out at:
Bad news first…
there was a bug with the outputdir variable used in the script. But the bug has been fixed now so that it is now possible to define the exact output directory.
Good news for Windows users
The script does work on Windows too! Just use the git bash and run the script like you would normally do on linux in bash!
I added some info to the Readme on Github how the script can be installed globally.
Would love to get some feedback on this project and if is useful or how it could be improved?
Why did I make the project at first? Simply because to give something back to the community. And since the community and official MonoGame devs did an awesome job with providing the possibility because everything can be done very easy now by using the. NET Core CLI to set up a complete solution.
The idea was to be able to quickly generate fully functional and portable solutions e.g. for simple testing or to provide the foundation for being able to quickly port XNA and / or MonoGame solutions / projects from older versions.
I tested that more project templates can be added to the solution. But although working on that part would be great this would complicate things more and thus require even more time because at least at the moment under Linux it is not possible to add project templates to a solution if the target is not available. With target I mean DirectX for example. That is a. NET Core limitation AFAIK which maybe will change in the future at some point.
I could add more versatile configuration possibilities with command line options. But I wanted to keep things very simple in the beginning so that also developers without knowledge about shell scripting are able to quickly figure out what is going on in the script.
Maybe the Readme / documentation can be written in a more understandable way?
I think I will add this option together with more options as command line parameters.
Until I find some time to work on the project… For a quick solution you could just add a command which deletes the sln file at the end of the script or you can try to edit the script so it does not generate the sln file in the first place. Without having looked at it in detail I think this should work by just commenting out the corresponding dotnet sln commands which are all in one script / code block at the end of the script.
How flexible are dotnet project templates? Can I have a project template that is customizable when applied so that a user of the template can create different setups? With setups I mean different combinations of MonoGame project templates.
The info in this post is valid for commit df1fb9044a3ca641a083064efdbadace316c8a23.
It is not really tested but you could try it out if you like. For this state the solution file is not created by default since this is what you asked to have an option for. You can pass an argument -s or --solution to enable it again. Also by default it should generate the mgnetstandard and the mgdesktopgl project. If you pass the option -w or --mgwindowsdx it should also create a windows dx project.
So to sum it all up to have it generate no solution just run the script like before… monogame-kickstarter generateogl
To make it generate a solution again use monogame-kickstarter -s generateoglandsln
You are welcome to leave feedback again if you want to try the script at this point.
The information in this post is valid for commit 38f8a44f65e6be19c19eaf3a8f6b771c249550c1 on the develop branch.
Things are changing a bit again in the latest commit(s) on the develop branch. I wanted to have the default of a solution file generated. At this point only opengl and directx project generation is implemented. You can now deactivate solution file generation by using the capital S command line parameter e.g. to have it only generate the opengl project but no solution file use: ./monogame-kickstarter.sh -So noslnonlyopengl
To generate a solution file you don’t have to pass anything just omit the capital S. If I will change the default to not generate a solution file I will likely use the lower case s to activate it.
On Windows in git bash you can use the -w option to generate the windows directx template project. So e.g. ./monogame-kickstarter.sh -Sow noslnopenglandwindx will create no solution but the opengl and the win directx project
I think as the script is getting longer it is maybe the right time to refactor / clean it up before merging the develop branch back to the master branch.
At this point I am just happy that it is now possible for both linux and windows users to let monogame-kickstarter handle the setup of a multi platform solution with shared code and shared content with the possibility to choose if you want to have it generate an opengl / windx / or both projects!
In realized that if the MonoGame Windows DirectX template is working the MonoGame Android template maybe will work on Windows too. So I am checking that right after having updated my Visual Studio 2019 Community Edition so that it has Xamarin installed which is required for Android.
Also I am wondering if bash scripts can be run on MacOS? Unfortunately I don’t own a Mac to test especially the MonoGame Kickstarter sctript…
Unfortunately it did not work. The project gets created but I cannot add a reference to the .NET Standard Library project without error. I tested the script with git bash. Maybe it would work with Powershell but I am aiming for something that will work the same in bash and git bash before thinking about supporting multiple shells / terminals But if somebody wants to play around with it I checked in an android branch to the repository. To activate the creation of an android project you need the -a command line parameter. So the command monogame-kickstarter -aow mytestsolution will e.g. try to setup a solution and three (with the .NET Standard Library four) projects: Android, DesktopGL and Windows DirectX.
I managed to find some time to improve the script and clean it up a bit. I merged the develop branch back to the master branch and added some more info to GitHub / updated the Readme.
For now the default is that the Desktop GL project is generated by default since it can be created and started under linux and windows. But of course by editing the script anyone can change this behaviour so that nothing is generated by default or the Desktop GL and Windows DirectX projects are always generated both by default.
When either is not generated by default the parameter options to enable them are -o (Desktop GL) and -w (Windows DirectX).
So regardless of the defaults the command monogame-kickstarter.sh -ow myname will generate both projects. The generation of the Windows DirectX project will not work under Linux though so the default is that only the Desktop GL project is generated.
Today I realized the part for the Android project has to be done a little different because since it is Android we now deal with an Activity1.cs rather than a Program.cs. A manual test showed that it is possible to set everything up so that the shared content is also used by the Android project. So the next step is to figure out how to automatically do everything via MonoGame Kickstarter meaning putting the manual steps into the monogame-kickstarter.sh script. But it is probably more than this alone because I think git bash now gets in the way and from there the Android target is not available. So the dotnet commands for adding the reference to the .NET Core Standard project (to the Android project) and then later the adding of the Android project to the solution file is not possible without getting an error. The errors I am getting from the git bash command line are:
################################################################################
The template "MonoGame NetStandard Library" was created successfully.
################################################################################
The template "MonoGame Cross-Platform Desktop Application (OpenGL)" was created successfully.
Reference `..\auto.NetStandardLibrary\auto.NetStandardLibrary.csproj` added to the project.
################################################################################
The template "MonoGame Android Application" was created successfully.
Project `C:\MonoGame.Kickstarter\auto\auto.Android\auto.Android.csproj` could not be evaluated. Evaluation failed with following error:
The imported project "C:\Program Files\dotnet\sdk\3.1.401\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.401\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk. C:\MonoGame.Kickstarter\auto\auto.Android\auto.Android.csproj.
Usage: dotnet add <PROJECT> reference [options] <PROJECT_PATH>
Arguments:
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
<PROJECT_PATH> The paths to the projects to add as references.
Options:
-h, --help Show command line help.
-f, --framework <FRAMEWORK> Add the reference only when targeting a specific framework.
--interactive Allows the command to stop and wait for user input or action (for example to complete authentication).
################################################################################
The template "Solution File" was created successfully.
Project `auto.NetStandardLibrary\auto.NetStandardLibrary.csproj` added to the solution.
Invalid project `C:\MonoGame.Kickstarter\auto\auto.Android\auto.Android.csproj`. The imported project "C:\Program Files\dotnet\sdk\3.1.401\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.401\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk. C:\MonoGame.Kickstarter\auto\auto.Android\auto.Android.csproj.
Project `auto.OpenGL\auto.OpenGL.csproj` added to the solution.
Also when I try to run it with the dotnet run command:
dotnet run --project auto/auto.Android
C:\MonoGame.Kickstarter\auto\auto.Android\auto.Android.csproj(76,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.401\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.401\\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk.
The build failed. Fix the build errors and run again.
With Powershell:
dotnet run --project auto/auto.Android
C:\MonoGame.Kickstarter\auto\auto.Android\auto.Android.csproj(82,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.401\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.401\\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk.
The build failed. Fix the build errors and run again.
The last post is a bit long and nobody likes to read verbose stuff…
I guess the main problem which is blocking me at the moment is that like the errors above tell me there is no Xamarin folder at the mentioned path and so no targets file which is required for the commands to work properly:
C:\MonoGame.Kickstarter\auto\auto.Android\auto.Android.csproj(76,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.401\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.401\\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk.
I noticed there is a double backslash in the error message… Is this normal? Could somebody try / test if they can generate an Android project from the git bash command line and / or from the Powershell?
Or does somebody know if I need to update anything? Where are those targets supposed to be?
The project generation works with the script. And in Visual Studio I can add the project to the solution and also the reference to the net standard project. So everything should work I guess from the command line to but it doesn’t
I searched for the Xamarin.Android.CSharp.targets file and I found one at
At this point some testers with Windows 10 and installed git / git bash would really be helpful to check if this issue(s) are related to my setup / configuration or it is something other than that.
I pushed everything to the GitHub repository onto the android branch.
Testing is as easy as follows:
git clone / change to the android branch.
open git bash and cd to the cloned repository
run ./monogame-kickstarter.sh test
This will generate a folder named test and try to setup the solution and projects (default OpenGL and Android at the moment). Make sure you have installed the requirements like Xamarin via Visual Studio installer. If you are able to target Android under Linux the information if the script works in this case would also be helpful.
Would a template solution be flexible meaning I can choose which projects I want to have each time I use it? Where can I get more information how to setup templates with MonoGame projects? I mean like what would the work flow look like? What is your advice how to set this up?