kwsch / PKHeX

Pokémon Save File Editor
https://projectpokemon.org/pkhex/
Other
3.73k stars 700 forks source link

Build with .NET Core 3 #2198

Closed ghost closed 5 years ago

ghost commented 5 years ago

Winforms/WPF is now open source and .NET Core includes support for them according to https://blogs.msdn.microsoft.com/dotnet/2018/12/04/announcing-net-core-3-preview-1-and-open-sourcing-windows-desktop-frameworks/ . What effort needs to be done in order to compile this application under .NET Core 3?

kwsch commented 5 years ago

I've kept dependencies of PKHeX.WinForms to a minimum; only dependencies are:

There's one pinvoke done for windows builds to load the gen6 font file (see FontUtil.cs), which may be the only problem in the codebase that would need to be reconfigured. It's the only reason there's a mono build; no other special considerations :)

As for building, I wasn't able to figure it out yet -- I installed VS 2019 preview and the 3.0 sdk&runtime and couldn't change the build target for PKHeX.WinForms from .NET Framework 4.6 to .NET Core 3 (didn't show up in the list). Maybe need to wait for some dust to settle before a clear path is shown.

@evandixon migrated PKHeX.Core to netcore previously; maybe he would have an idea ;)

The porting guidelines can be found here: https://github.com/dotnet/winforms/blob/master/Documentation/porting-guidelines.md

The portability tool comes back clean: image

evandixon commented 5 years ago

As for building, I wasn't able to figure it out yet -- I installed VS 2019 preview and the 3.0 sdk&runtime and couldn't change the build target for PKHeX.WinForms from .NET Framework 4.6 to .NET Core 3 (didn't show up in the list). Maybe need to wait for some dust to settle before a clear path is shown.

@evandixon migrated PKHeX.Core to netcore previously; maybe he would have an idea ;)

.Net Core uses a new project type, and while I absolutely adore it, I don't know of a way to move from the old to the new without creating a brand new project, copying the files over, and fixing whatever syntax errors there may be.

One thing to watch out for is the text resources. .Net Core 1.x and 2.x don't seem to play nice with .resx files having text files that are treated as strings, hence some stuff I had to do in DataUtil that feels bad.

I've kept dependencies of PKHeX.WinForms to a minimum; only dependencies are: QRCoder, which isn't GUI and is only tied to System.Drawing pokesprite, which is only tied to System.Drawing like all other image resources.

I haven't tried it, but System.Drawing is in .Net Core, and as of 2.1, it does contain things like Bitmap. Api reference: https://docs.microsoft.com/en-us/dotnet/api/system.drawing?view=netcore-2.1

There's one pinvoke done for windows builds to load the gen6 font file (see FontUtil.cs), which may be the only problem in the codebase that would need to be reconfigured. It's the only reason there's a mono build; no other special considerations :)

AFAIK you can still use DllImport in .Net Core. It feels wrong doing so in .Net Core, but since Windows Forms is, well, Windows-only, it works.

kamronbatman commented 5 years ago

There is a migration tool (I have been told) for .NET Framework 4 to .NET Core 2.0/2.1 (not sure about 3.0). I assume there is still manual work to be done to get it to work properly though.

SubstituteR commented 5 years ago

I've been able to build for both .net 4.5 and net core 2.0 from the same project. There should be some information you can change in the proj file directly.

kwsch commented 5 years ago

@SubstituteCS the PKHeX.Core portion can be built for both, but the WinForms project uses the 4.5 dll.

The WinForms portion doesn't have an option to build with netcore currently

kwsch commented 5 years ago

Status update:

.NET Core 3 still isn't out yet, and recently (3 days ago) hit Preview 4. https://devblogs.microsoft.com/dotnet/announcing-net-core-3-preview-4/

.NET Framework 4.8 also came out (3 days ago), but I don't plan on requiring it. People complained about the 4.0/4.5 bump to 4.6... :) https://devblogs.microsoft.com/dotnet/announcing-the-net-framework-4-8/

kwsch commented 5 years ago

Status update:

.NET Core 3 has been officially released. https://dotnet.microsoft.com/download/dotnet-core/3.0

I'll have to explore things before deciding :)

Some negatives:

Adding in different build options might be possible (to have both netcore / netframework)