Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builds on .NET 4.7.2 #3756

Closed
wants to merge 4 commits into from
Closed

Builds on .NET 4.7.2 #3756

wants to merge 4 commits into from

Conversation

unquietwiki
Copy link

#3755 was a dead-end: between the LINQ IEnumerable calls, and the changes in SSL/TLS support in 4.7.2, re-targeting to 4.7.2 solves the following issues...

  • Compatible with VS 2022+
  • Compatible with Windows 7,8,10,11 (and related Server builds)
  • Most users should already have this or 4.8.x installed via Windows Update, or more recent OS inclusion.
  • Resolves build issue demonstrated in https://stackoverflow.com/questions/62543481/tohashset-ienumerablestring
  • Connects to remote servers correctly, unlike the "hacked" attempt to use 4.5 in VS 2022.
  • .NET Framework 4.7.2 came out almost five years ago; 4.8.1 came out a few months ago, and had dropped support for the older OSes 4.7.2 was supporting.

Tests passed: 852 of 860; one of failures was an unpack test, but I could still use the app successfully to uninstall & install mods. The previous 4.5-oriented build didn't even get halfway through the tests.

I hope this balances the compatibility concerns for the user base and the ability to develop further on the software.

@unquietwiki
Copy link
Author

unquietwiki commented Jan 3, 2023

Looking at the code with SonarLint, ModuleInstaller in Tests has a missing assert that matches the failed unpack test; so maybe that test was a false result?

@unquietwiki
Copy link
Author

ilrepack_successful_command.txt

Okay, I dug into where ILRepack was having problems. This sequence works for me locally.

Tests/Tests.csproj Outdated Show resolved Hide resolved
Tests/Tests.csproj Outdated Show resolved Hide resolved
@HebaruSan
Copy link
Member

Looks like this is the current build error.

ERROR: Failed to load assembly /__w/CKAN/CKAN/_build/out/CKAN-CmdLine/Debug/bin/net472/ICSharpCode.SharpZipLib.dll
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
  at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x000f7] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00007] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.DefaultAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00025] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00040] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00006] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.TypeReference.Resolve () [0x00006] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum (Mono.Cecil.TypeReference enum_type) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue (Mono.Cecil.TypeReference type) [0x0002f] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElement (Mono.Cecil.TypeReference type) [0x00015] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument (Mono.Cecil.TypeReference type) [0x00015] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeConstructorArguments (Mono.Cecil.CustomAttribute attribute, Mono.Collections.Generic.Collection`1[T] parameters) [0x0002e] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.MetadataReader.ReadCustomAttributeSignature (Mono.Cecil.CustomAttribute attribute) [0x0003c] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.CustomAttribute.<Resolve>b__34_0 (Mono.Cecil.CustomAttribute attribute, Mono.Cecil.MetadataReader reader) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00025] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.CustomAttribute.Resolve () [0x00017] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.CustomAttribute.get_ConstructorArguments () [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadCustomAttributes (Mono.Cecil.ICustomAttributeProvider provider) [0x0001b] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadModule (Mono.Cecil.ModuleDefinition module) [0x00085] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.<ReadModule>b__1_0 (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataReader reader) [0x00007] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00025] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadModule () [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleReader.CreateModuleFrom (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x0006a] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00028] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000a] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.ILRepack.ReadInputAssembly (System.String assembly, System.Boolean isPrimary) [0x00151] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.ILRepack.ReadInputAssemblies () [0x00048] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.ILRepack.Repack () [0x0002f] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.Application.Main (System.String[] args) [0x0004a] in <fa257496929944d3922e0349a0420534>:0 
An error occurred when executing task 'Repack-Ckan'.

@unquietwiki
Copy link
Author

@HebaruSan taking a look, thanks for the heads up. I told it to pull in all the new commits, so I'll see how that impacts things, and will report back.

@unquietwiki
Copy link
Author

@HebaruSan I found the missing NuGet include, and my latest build does run for me. Sneaky because it was building in VS just fine, though still missing that dependency.

@HebaruSan
Copy link
Member

Now it says this:

ERROR: Failed to load assembly /__w/CKAN/CKAN/_build/out/CKAN-CmdLine/Release/bin/net472/ICSharpCode.SharpZipLib.dll
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
  at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x000f7] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00007] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.DefaultAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00025] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00040] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00006] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.TypeReference.Resolve () [0x00006] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum (Mono.Cecil.TypeReference enum_type) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue (Mono.Cecil.TypeReference type) [0x0002f] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElement (Mono.Cecil.TypeReference type) [0x00015] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument (Mono.Cecil.TypeReference type) [0x00015] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeConstructorArguments (Mono.Cecil.CustomAttribute attribute, Mono.Collections.Generic.Collection`1[T] parameters) [0x0002e] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.MetadataReader.ReadCustomAttributeSignature (Mono.Cecil.CustomAttribute attribute) [0x0003c] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.CustomAttribute.<Resolve>b__34_0 (Mono.Cecil.CustomAttribute attribute, Mono.Cecil.MetadataReader reader) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00025] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.CustomAttribute.Resolve () [0x00017] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.CustomAttribute.get_ConstructorArguments () [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadCustomAttributes (Mono.Cecil.ICustomAttributeProvider provider) [0x0001b] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadModule (Mono.Cecil.ModuleDefinition module) [0x00085] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.<ReadModule>b__1_0 (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataReader reader) [0x00007] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00025] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadModule () [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleReader.CreateModuleFrom (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x0006a] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00028] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000a] in <fa257496929944d3922e0349a0420534>:0 
  at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.ILRepack.ReadInputAssembly (System.String assembly, System.Boolean isPrimary) [0x00151] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.ILRepack.ReadInputAssemblies () [0x00048] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.ILRepack.Repack () [0x0002f] in <fa257496929944d3922e0349a0420534>:0 
  at ILRepacking.Application.Main (System.String[] args) [0x0004a] in <fa257496929944d3922e0349a0420534>:0 
An error occurred when executing task 'Repack-Ckan'.

FYI, you can always see the latest errors on the Checks tab, or by clicking Details in the box at the bottom of the PR page.

@unquietwiki
Copy link
Author

@HebaruSan I looked at the include again: the newer version of SharpZipLib was asking for .NET Standard 2.0; which from what I know in the Unity/Kerbal space, there's a choice between .NET 4.x and Standard 2.x for builds, and this build setup is meant for the former. It was probably working just fine for VS builds, but not for Mono builds. I've reverted the version of the library to try to avoid that dependency.

@unquietwiki
Copy link
Author

@HebaruSan Okay, that's a better outcome. There's some Docker timeout on two of the builds, and the remaining two seem related to whatever you were using .Net 5 for (I don't fully understand how you were able to make that work; it seems only Core & Tests use it). The rest worked!

@HebaruSan
Copy link
Member

Cool, yeah, that's progress. 🎉

We do need all the tests to pass before merging, though, and I don't have the spare cognitive bandwidth to dig into this. Maybe try reverting parts till you find out what breaks it?

@unquietwiki
Copy link
Author

@HebaruSan I'll see what I can figure out. 👍 If you can tell me what you were trying to do with .NET 5, as you can remember, that'd be a good help. One other thing regarding that: .NET 6 is the current LTS, so whatever you're doing with 5 should probably move to that.

@HebaruSan
Copy link
Member

HebaruSan commented Feb 19, 2023

I think you can find most of it in the git log for the core csproj. Originally @jbrot submitted .NET Standard 2.0 support in #2820 with plans to create a new Mac GUI that never materialized (unless he did it and just never told us), then later @DasSkelett updated that to .NET 5 in #3194 in anticipation of a future MAUI GUI, before Microsoft announced that would leave Linux and Mac users out in the cold.

So it's not in use, but it creates opportunities to migrate to more modern platforms.

@unquietwiki
Copy link
Author

Thanks for that; that's helpful! When I first started looking at this, I was trying to follow some of what's suggested by Microsoft, regarding migration to .NET 5-7. I can try to figure out how to at least fix the build issue; otherwise, a separate branch using the other migration tools might yield the desired upgrade.

@unquietwiki
Copy link
Author

@HebaruSan I noticed in the logic there were calls to two different file managers, depending on .NET5 vs 4.x. I took care of trying to fix that reference, tried calling on .NET6, and disabled a 4.5-specific Hashset method (LINQ seems to provide it). Still don't have an easy way to test on my end: VS doesn't like it that most of the other projects don't target the newer framework, even with added references to try that.

@HebaruSan
Copy link
Member

Still don't have an easy way to test on my end

I think you can run this from the command line:

.\build.ps1 test --configuration=Debug_NetCore

@HebaruSan
Copy link
Member

And yes, ToHashSet was added to .NET Framework in 4.7.2, after CKAN had been using its own implementation of the same function for several years. That's why it has that #if NET45 check.

https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.tohashset?view=netframework-4.7.2

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 4.7.2, 4.8, 4.8.1
.NET Standard 2.1

@unquietwiki
Copy link
Author

unquietwiki commented Feb 19, 2023

@HebaruSan that helped, thanks. I merged the last few commits that were coming up to the .NET5 build issue; and also gave up on using .NET6, since the builder on here is still on .NET5 (and the local compiler warned me plenty .NET5 is EOL).

Regarding the incompatibility warnings I keep seeing... the messages I saw involved two of the libraries being potentially incompatible with .NET 5. One's CommandLineParser: I tried creating separate references between the current one and a .NET Standard version for .NET 5 to use; that just confused VS; going to version 2.x on that library requires a partial re-write of the code here. The other was iniparser: having the .NET Standard version alongside isn't throwing any immediate errors.

Edit: what do you know, Mono did hate that extra iniparser reference. Removed!

@HebaruSan HebaruSan added GUI Issues affecting the interactive GUI Cmdline Issues affecting the command line Core (ckan.dll) Issues affecting the core part of CKAN labels Mar 1, 2023
@HebaruSan HebaruSan added Pull request Build Issues affecting the build system ConsoleUI Issues affecting the interactive console UI Netkan Issues affecting the netkan data AutoUpdate Issues affecting the automatic updating Tests Issues affecting the internal tests labels Mar 1, 2023
@HebaruSan
Copy link
Member

@unquietwiki, if you come back to this, please let us know and we can re-open it. Closing to reduce inactive stuff accumulating in the queue.

@HebaruSan HebaruSan closed this Mar 10, 2023
@unquietwiki
Copy link
Author

@HebaruSan hey there, checking in; sorry for the delay. I'd like to finish this, but I guess I need some help from someone that worked on the original .NET 5 hooks & if they're even needed anymore. I also feel like since .NET 5 is EOL, the tests should be updated to .NET 6 LTS; that's a call you'd have to make. Let me know your thoughts. Thanks.

@HebaruSan
Copy link
Member

I don't think you're going to get that help; as sometimes happens, you're the one that's interested in this, so whatever you can figure out is what will get done. Good luck!

@unquietwiki
Copy link
Author

Thanks @HebaruSan. BTW, somewhat related to this: I saw a PR #3131 that updates CommandLineParser. That probably needs some love to ensure it still works, but that is a dependency issue I ran into on my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoUpdate Issues affecting the automatic updating Build Issues affecting the build system Cmdline Issues affecting the command line ConsoleUI Issues affecting the interactive console UI Core (ckan.dll) Issues affecting the core part of CKAN GUI Issues affecting the interactive GUI Netkan Issues affecting the netkan data Tests Issues affecting the internal tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants