I have been following the book Monogame Mastery and have simply copied the project for each folder, renamed it, renamed and edited the .sln and .csproj files and it opens perfectly ready for the next chapter.
If I move any of the project sub- folders into a different folder eg from C:\Chapters\Chapter11 to C:\Template\Chapter11 then all the monogame references are lost.
I am using VS 2022 so the packages are not available on Nuget, I have to use cmd to create a new project.
Is there somewhere that VS 2022 holds a list of ātopā folders that have the Monogame libraries, so they work in all subfolders, or am I missing something?
Not sure this is what you want to hear but it is for most users the most straightforward method, install VS2019 alongside VS2022, create project in VS2019, run, close, and then open in VS2022.
I recall hearing of a soon to be released update to MG, which will address the templates and NUGET, but for now, this works.
Someone might drop by and give you the command line method at some point, though you could probably find it if in a hurry to try it.
If you need help finding the VS2019 installer, just ask.
Thanks for the suggestion. The wierd thing is when I load my āmovedā project and open it either with vs 2019 or vs2022 the same thing happens: (This image is constructed from VS2019, but is identical in 2022)
Changing the IDE was never going to work, because NuGet and their packages works independently from IDEs. Itās when you change TargetFrameworks you may want to make sure your packages are compatible.
I bet you just need to regenerate the files that keep track of the package resolutions since the paths to the packages have changed. Usually the downloaded packages are located inside a folder āpackagesā in the same directory as the solution so they shouldnāt have moved.
Try deleting the obj folder where your project is, maybe delete the bin folder too for good measure. Force a package restore (I forget to do this in Visual Studio) by typing dotnet restore Chapter11.csproj. If the restore went well, it should definitely find the namespaces so you can try and build.
I spent several hours creating a new project called āGameEngineTemplateā and copy/pasting all the code from my original āChapter 11ā solution, got it working, then copied the whole thing to a different location.
It worked perfectly, so I still do not know what was causing the issues with the original project. The only difference was the assets in the mgcb of the original were links to the images etc, but in the new version they were copied into the local project.
I cannot see how that would make any difference as they are only assets and would have caused run-time errors if not found, rather than the monogame libraries not being registered.(surely?)
Just in case, I tried copying āChapter 5ā to C:\test and it had the same errors as chapter 11, so I changed the assets in mgcb to ācopy to folderā (while still in itās original location), built and ran to make sure it worked.
This time when I copied it to C:\test, everything worked normally!
Next experiment:
copy the assets folder to C:\test
Guess what: All OK!
Conclusion:
If you are copying/moving a project and you have assets that are in a separate location and referred to by links in mgcb, copy that as well!
Hopefully this post will help somebody with a similar issue in the future