Wrong MonoGame paths when using template I create from a MonoGame project

I made a MonoGame project and exported it as a Visual Studio template file.

When I create a new project from that template inside Visual Studio default project folder (in my case, **C:\Users\Ronen\Documents\Visual Studio 2015\Projects**), everything works fine and it builds and compile out of the box.

However, if I try to use the template outside the default Visual Studio folder, for example here: C:\Users\Ronen\Documents\test, I’m getting the following build errors:

1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x86\SDL2.dll" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x64\SDL2.dll" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x86\soft_oal.dll" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x64\soft_oal.dll" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x86\libSDL2-2.0.so.0" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x64\libSDL2-2.0.so.0" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x86\libopenal.so.1" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x64\libopenal.so.1" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\libSDL2-2.0.0.dylib" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\libopenal.1.dylib" because it was not found.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4106,5): error MSB3030: Could not copy the file "C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll.config" because it was not found.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

As you can see, MonoGame searches for its assemblies in the wrong place!

I’m pretty sure I don’t have Users/Program Files (x86) on my computer… (note the “C:\Users\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\x86\SDL2.dll” part). Whats even stranger, is that if I put in different folders I get different random paths. For example if I put in c:/projects/something/ I get paths like C:\Users\Ronen\AppData\Program Files (x86)…

I think it has something to do with this variable $(MonoGameInstallDirectory) which Visual Studio use to copy MonoGame files. For some reason it gets terribly broken when using templates… Probably it uses some relative path somewhere, which explains why it works when I put my project in Visual Studio’s default projects dir.

I could fix it manually for every project I create from the template, but I want to release the template itself for other people so I need to fix that in the template level.

Any ideas how to solve this problem? And should I report it to MonoGame team or am I just doing something wrong here?

I searched for “MonoGameInstallDirectory” definition anywhere inside the template zip but couldn’t find where its defined.

Thanks!

Edit:

BTW this is super easy to reproduce (visual studio 2015):

  1. Create new MG cross desktop project.
  2. Export as template.
  3. Use template to create a project anywhere but the default Visual Studio projects dir.

The simpler answer may be to switch your Original MonoGame project to use the NuGet downloads.

You should be able to use

$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies

As this is defined when you install MonoGame using the installer.

Note that the dependencies were not yet included in the 3.6 release nugets, so you’ll need to get the develop ones.

I’ll give it a try…

I agree it doesn’t make much sense that it doesn’t work… But that’s what happens. I even tried the template on another PC and I have the same problem - creating in default projects dir = ok, creating anywhere else = error.

Btw, if I create in the default projects dir and then move it to any other directory its also ok. So I can at least move projects around :slight_smile: This makes me feel like it might be a problem with VS templates and not MG itself.

What do you mean? Is this nuget not ok?

There was an issue in the base 3.6 release. Not sure if the updated NuGet is out yet. Try it and if it doesn’t work, use this feed:
http://teamcity.monogame.net/guestAuth/app/nuget/v1/FeedService.svc/

2 Likes