This tutorial will guid you step by step through the path of integrating the MonoGame-PipelineTool into your MonoGame.Forms project.
With this tool it's possible to directly compile your content files to the .xnb file format - ready to be used by the MonoGame ContentManager!
As a starting point we will use a fresh WindowsForms project on a Windows machine, which has nothing - related to the MonoGame.Framework - referenced.
Let's start!
Part I:
- Create a fresh WindowsForms project
- Install the MonoGame.Forms.DX library
- PM> Install-Package MonoGame.Forms.DX -Version 2.1.0.2 (exchange with the version you want to use) OR
- Browse through the NuGet Package-Manger from within Visual Studio
- Create a new folder and name it "Content"
- Add a .txt file to this folder and name it "Content.mgcb"
- You will get an error saying that the project couldn't be opened, because of an unknown error
- Click "Ok" on this message box
- The PipelineTool should now be opened with an empty project
- Close the PipelineTool now
- Open the "Content.mgcb" file with a regular text editor (like the windows Notepad or Notepad++)
- Paste the following lines to the .mgcb file and save it:
#----------------------------- Global Properties ----------------------------#
/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:Windows
/config:
/profile:Reach
/compress:False
#-------------------------------- References --------------------------------#
#---------------------------------- Content ---------------------------------#
- When you now double click on the Content.mgcb file it sould open the PipelineTool without errors and it should display your content project
We are done with the preperation!
... but we are not finished yet. We need to make sure, that our content files correctly getting built and copied to the output directory.
Part II:
... if you want to call it like this ;)
- Open your WindowsForms .csproj file with a regular text editor (like the windows Notepad or Notepad++)
- Paste the following line directly to the first
<PropertyGroup>
:<MonoGamePlatform>Windows</MonoGamePlatform>
- Scroll right to the end of this file and paste the following line right behind the Microsoft.CSharp.targets line:
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
- Save your changes and open Visual Studio again
- You will be greeted with a prompt. Just tell him to reload everything
- Now select the "Content.mgcb" file and in the Visual Studio property panel under Build Process choose the MonoGameContentReference option
- Add a test file by using the PipelineTool (e.g. TestFont.spritefont) and save the content project
- If you now rebuild or run your WindowsForms project you will see a "Content" folder with the compiled "TestFont.xnb" file in your output directory
- Use this file with your ContentManager (e.g.
Editor.Content.Load<SpriteFont>(@"TestFont");
- Be Happy!
This should boost your "content compiling workflow" by alot!
Feel free to ask questions if something is not clear enough.
You can reach me on Twitter:
or visit the official MonoGame.Forms_Thread