Complete beginner here. Very familiar with GameMaker, wanted to move on to something that gives me more control (and just learn for fun).
Following the official MonoGame 2D game tutorial (it won’t allow me to link it here because I’m a new user).
Chapter 4 asks me to add a class library. As soon as I do that, the whole game refuses to build. “[Game Directory] Failed to build” is all it tells me on the pop up. In the terminal it gives 7 errors, all coming from AssemblyInfo.cs. All the errors are the exact same, just on different lines and go as such: error CS0579: Duplicate ‘System.Reflection.AssemblyConfigurationAttribute’ attribute
I looked online and either the responses are too advanced for my feeble mind, or are completely unrelated to my issue.
I have changed literally nothing about the template except for adding a class library exactly as specified in chapter 4. If someone could help me understand what’s wrong here, I’d seriously appreciate it. I just want to learn but I’m at a complete roadblock.
CH4 looks pretty straightforward so maybe there’s been some code drift between CH1 and now. It’s also possible that your environment isn’t set up correctly.
Have you taken a look at the end of chapter 4 sample on their github? It’s at github MonoGame/MonoGame.Samples/tree/3.8.4/Tutorials/learn-monogame-2d/src/04-Creating-A-Class-Library (sorry, new user so I can’t post links either). Pull that down and see if it will build. You can then do a diff to see how your project differs from the official source.
The AssemblyInfo.cs should not be needed for modern .net since it gets auto generated. You can probably just delete that file. Not sure why it was created in the first place though.
Glad you have confirmed it is the library causing the issue. But also potentially sounds like the library is in the wrong folder, or included within your project.
Try creating one of the Starter kit templates and compare (or use it as a starting position) dotnet new mg2dstartkit -o myawesomeexampleproject
(Oh and do not use spaces, numbers or special characters in the path, dotnet no likey)
I followed the exact instructions inside the tutorial and got the same error as well. I had to ask LLM to solve this problem.
Manually go to DungeonSlime project and delete obj folder.
Add these into DungeonSlime.csproject under first <PropertyGroup> <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
then do dotnet clean, dotnet restore and dotnet build from the terminal.
The project should build now. I am not sure if it’s the right approach but it worked for me for now.
I’m sorry for the frustration in following the tutorial and coming to that issue. As it was pointed out, this error message is caused by an AssemblyInfo.cs or similar that should not have been created or happened when following the tutorials steps.
I just went through chapters 1 - 4 and was not able to reproduce this issue. I would like to narrow it down though so I can update the tutorial if it needs to be. Would you be able to do a quick pass of the steps in chapters 1 - 4 in a new project and see if it happens again? If you’re in the MonoGame discord, feel free to ping me there (same username as here) as well or DM and I can try working with you to see what’s happening between the tutorial and on your system.
With .NET 10 just being released recently, and the new .slnx solution file format for project solutions, maybe something weird is happening?
Hi I was facing a similar issue when trying to follow the tutorial.
I am on Win 11 23H2 running the latest VS 22 (17.14.26) version available, with the 9.0 dotNet SDK. Is something wrong in the project template setup?. After adding the lib project the issue persists even with a git reset to a previously working project, implying that there’s some changes that happened in gitignored stuff for me, so o bin seems to check out? I did a ZIP copy my proj ‘cuz I wanna move on and maybe try to solve this issue myself in the meantime, I will update if I can fix this.
Hey new user here, I don’t have much knowledge about monogame yet, but i came acros this problem testing out Jetbrains Rider IDE. Had no issue in vscode, but rider created library within the project folder, so when I was trying to follow the dotnet CLI guide on creating the reference it had an error, and it could be referenced only if i changed the path (the one in the guide was not working), I managed to reference correctly, but hit all the errors that were mentioned in original post. What fixed it for me was that i rearanged folders so they wouldn’t be one inside the other. rather
Solution folder
—Dungeon slime
——-all the other things and .csproj file
—Monogame Library
——-all the other things and csproj file
This way i suppse since they were right by each other instead of one inside the other, there were no duplicates anymore