vchelaru / FlatRedBall

Cross-platform 2D game engine focused on ultimate productivity built in .NET
http://flatredball.com
MIT License
406 stars 65 forks source link

Support .NET 5 game project for DesktopGL #283

Closed vchelaru closed 2 years ago

vchelaru commented 2 years ago

Requirements:

Actually maybe the solution is to create a new SDK style project which doesn't require adding and removing explicitly. Can SDK style projects be used in .NET Framework?

Moving to .NET 5 specifically may not be as complex as moving to SDK style CSPROJ files. Therefore, it might be worth trying to create a SDK-style game project using .NET Framework 4.7X first before moving on to .NET 5. That way, Glue could be updated to support this without introducing multiple variables at once (.NET vs Framework, new MonoGame version with nuget, etc.

coldacid commented 2 years ago

Can SDK style projects be used in .NET Framework?

Yes, it's just a matter of specifying the appropriate framework target in the csproj file.

It will still be useful to explicitly add certain files to SDK-style projects since Visual Studio won't otherwise pick up on file dependencies (i.e. <DependentUpon>) otherwise unless the developer has installed VS extensions which handle that in the UI.

vchelaru commented 2 years ago

Update - Okay, so it seems that we can upgrade a .NET 4.7.1 project to .NET 6. I used this tool and it worked great:

https://github.com/dotnet/try-convert

After upgrading to .NET 6, I was able to build and run a FRB project in Visual Studio.

The problem comes from loading this project in Glue. First, when loading I ran into an issue loading .NET 6 projects in general:

https://stackoverflow.com/questions/73348274/how-to-load-net-6-project-in-a-net-6-console-application

The solution in this post solves the problems when trying to load .NET 6 projects in a .NET 6 console application. Unfortunately, doing this in Glue does not work.

Currently, Glue references Microsoft.Build libraries 16.9:

image

I don't know if this is why .NET 6 isn't loading, even with the environment variable assignment code.

But then I realized that one problem may be that I'm referencing msbuild nugets 16.9 here, but my console project that did work referenced 17.2. But after upgrading to 17.2 I ran into a different problem:

image

This error now happens on all projects, not just .NET 6 projects. It seems like we're looking specifically for 15.1 and upgrading from 16.9 -> 17.2 breaks this. Not sure why, because I didn't upgrade from 16.9.

However, Glue has a bunch of app.config files:

image

These explicitly redirect to 15.1, but I don't know why! I think this may have solved some earlier bug but I can't find a reference to it. It was added in commit 73aa66bbcaf93f7157419d0d7df42740ee3afa9c .

So, I think someone with a better understanding of msbuild will have to tackle this for me, because I really don't get the problem.

vchelaru commented 2 years ago

Update - I tried downgrading the project from .net 6 to .net 5. Then from .net 5 to .net core 3.1. Still won't load in Glue...

vchelaru commented 2 years ago

Fixed!!

image

008a05ba2be92ec0d9a2dd4f81c466d80cfc0f66

coldacid commented 2 years ago

Looks like I've got some work to do this weekend to switch over my project! Thanks for the hard work, @vchelaru!