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.
1 Like
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.
1 Like
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.
1 Like
Every time I launch the game, the file gets created anew… Any idea why that happens / how to stop it?
Where is it getting created? Do you have an AssemblyInfo.cs in a Properties folder in your project?
1 Like
Just to break this down and find the issue, can you tell us a few things:
- Which OS are you on
- Which editor are you using.
And a few questions:
- If you remove the library from your project, can you build again?
- When adding the library, did you select the
MonoGame Game Library or a normal dotnet Class Library ? (something we see often)
You can also check out the University video for this chapter to see if there is anything you missed.
Hope that helps
P.S. and don’t ask about the hat, I have no idea what I was thinking that week.
2 Likes
It’s getting created under obj > Debug \ net9.0.
I’m on Windows 10 using Visual Studio Code.
If I remove the library (and revert the code to what it was before I implemented the library), then the project runs just fine.
I’m sure I added the correct library, as I went through the tutorial a second time before posting, making sure every step was correct.
P.S. - That is a beautiful hat and I will check the video out
1 Like
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)
1 Like
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.
1 Like
Hey @Ellie_Babin
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?