MonoGame with XNA Content Pipeline

From Leo's Notes
Last edited on 4 March 2020, at 04:56.

Because MonoGame doesn't have the XNA content pipeline implemented, my current work around is to create a XNA game just for content pipeline and then copy the compiled contents to my MonoGame project.

The XNA project will have a Pre/Post-build event that does the compiling and copying: Pre:

"$(VS100COMNTOOLS)..\IDE\devenv" "$(SolutionDir)Presentation\Content\Contents\Contents\Contents.csproj" /Rebuild

Post:

REM Copy the compiled XNA contents to the build directory.
xcopy "$(SolutionDir)Presentation\Content\Contents\Contents\bin\x86\Debug\Content" "$(TargetDir)Content" /s /e /i /y

Troubleshooting[edit | edit source]

Error loading pipeline assembly[edit | edit source]

On Visual Studio 2019, whenever I attempt to build a XNA Game with a game content, I get the following error:

error loading pipeline assembly "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Framework.dll". GameContents

The fix is to add the DLL assembly into the global assembly cache. Open a "Developer Command Prompt for VS 2019" as Administrator, then run:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0>cd  "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64"

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64>gacutil /i Microsoft.Build.Framework.dll
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

Search the C drive for Microsoft.Build.Framework.dll if you can't find it int he path above.