I have recently installed Visual Studio 2019 Community and Monogame 3.8 on Windows, following this guide.
Now, I am very new to both C# and Monogame, so I hope you will forgive this question, but: when I create a new game with a Monogame template everything seems to work as intended. Whenever I load an example or tutorial however, VS2019 displays the following message:
error: The imported project “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\MonoGame\v3.0\MonoGame.Content.Builder.targets” was not found
(Or, in more detail):
tldr
C:\Users\info\Downloads\TexturePacker-MonoGame-Demo-master\TexturePacker-MonoGame-Demo-master\TexturePacker-MonoGame-Demo.csproj : error : The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\MonoGame\v3.0\MonoGame.Content.Builder.targets" was not found. Also, tried to find "MonoGame\v3.0\MonoGame.Content.Builder.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Users\info\AppData\Local\Microsoft\VisualStudio\16.0_bc8db59d\devenv.exe.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths. C:\Users\info\Downloads\TexturePacker-MonoGame-Demo-master\TexturePacker-MonoGame-Demo-master\TexturePacker-MonoGame-Demo.csproj
I think these examples were written for older versions of Monogame? I’ve searched both my PC’s directories and the internet for the file and a solution respectively, but to no avail. Can someone explain what is going on and how I can solve it? Thank you!
I know this is an old issue, but i’m having exactly the same issue when setting up a new computer to work, and I haven’t found any decent explanation, most answers being misleading.
This problem seems to happen when you’re trying to load a project created with an old version of MonoGame, and you install the 3.8 monogame extension for VS2019. The .csproj file tries to find a file in a place is no longer created by the new installers.
You probably have two solutions here:
Install an old version of MonoGame so that it creates the files. The MonoGame dlls will be stale, but you’ll have the build scripts. As you’ll probably be using nuget to keep monogame up to date this doesn’t matter.
I’ve used this way because I want the project file to work exactly the same in both computers, and I don’t want to mess with 3.8 in the old computer, but if you don’t have this requirement, option 2 will probably be better for you.
3.7.1 is probably your best option MonoGame 3.7.1
Modify the .csproj file so that instead of pointing to the old targets file, points to the correct place where the new targets file resides (no idea which is it, as I haven’t followed this path). You can even just delete the line (the content builder won’t work but the project will load) and then work from there afterwards.
The .csproj line is: <Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
I am trying to get MonoGame to run on Visual Studio 2022. I’ve tried downloading older versions of MonoGame and the installation seemed to work. However, I cannot get VS to “see” the installations.
When I load an example project, the projects come back as unloaded and so I cannot modify the code.
The error message is The imported project “C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\MonoGame\v3.0\MonoGame.Content.Builder.targets” was not found.
Please help.
So, the issue you are running into is due to how MonoGame worked prior to the 3.8.x version.
Prior to this, MonoGame was actually installed. All the dependencies it used, such as the file your missing in the error message (MonoGame.Content.Builder.target) was installed as part of this process.
With the 3.8.x versions of MonoGame, the extension you install in Visual Studio now is just installing the MonoGame dotnet new templates. If you create a new MonoGame project, you’ll notice in your .csproj file that it has the following lines
Those builder tasks are now part a NuGet package that is added as a reference to your project. Unfortunately, this means tutorials and example projects that use a MonoGame version prior to the 3.8.x versions will not work out-of-the-box because of this.
When using a tutorial or example project prior to 3.8, follow the steps in the Migrate guide to update it to 3.8. It’s not much to do to update it to 3.8, and can be done rather quickly. Information can be found here Migrating from 3.7 | MonoGame Documentation
Honestly because of how little needs to be done, option 2 is the best bet.
You also technically have a third option. Contact the person that made the example project and ask them to update it to current MonoGame version.