[SOLVED] MonoGame 3.8 Adding MonoGamePlatform Manually When Locally Cloned Versus Not When NuGet

Hey all, I’ve been trying to get a simple project going with the 3.8 pre-release NuGet packages. Specifically, I have an XBox One and XBox One X and I’ve been trying to get into a dev loop with deploying UWP games on them through the XBox Live Creators Program.

Long story short, using the NuGet packages of the 3.8 pre-release caused some issues (the program would run and then crash out after a half-minute or so), so I went to GitHub and cloned the current repo, set it to the develop branch, and proceeded to replace my NuGet references with the locally cloned project references instead. The good news is that it fixed the problems I was having and I was able to run the UWP games without issue.

However, in order to make it work, I needed to have this added to my UWP project’s .csproj file

<MonoGamePlatform>WindowsStoreApp</MonoGamePlatform>

This wasn’t necessary when referencing the NuGet package. I think this is due to this file maybe setting this automatically for me?

MonoGame.Framework.WindowsUniversal.targets.

Is there any way that when I reference the MonoGame.Framework.WindowsUniversal locally that I can replicate the same thing without also having to add this additional tag to my .csproj file?

Thanks to @jnoyola who replied on another question I had that actually solved this one.

In addition to the ProjectReference tag that gets added to the .csproj when it is referenced locally, there is the need to manually import the .targets file. So the fix for the Universal Windows project was adding the following (your path my vary based on where you cloned the project locally):

<Import Project="<Your repo path>\MonoGame\MonoGame\MonoGame.Framework\MonoGame.Framework.WindowsUniversal.targets"/>

I wish there was a way that when you use ProjectReference .targets and .props would import automatically like it does with PackageReference, but at least this resolves it.

More on the Import MSBuild tag can be found here:

https://docs.microsoft.com/en-us/visualstudio/msbuild/import-element-msbuild?view=vs-2019

1 Like