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

Repack netstandard facade in ckan.exe #4013

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

HebaruSan
Copy link
Member

Problem

The metadata tester crashed on KSP-CKAN/NetKAN#9917 despite its changes being simple and trivially correct:

https://github.com/KSP-CKAN/NetKAN/actions/runs/7749494610/job/21134148266

FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'CKAN.SteamLibrary+<>c__DisplayClass0_0:txtParser' (0) due to: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.

Cause

As of #4010, we now reference ValveKeyValue, which is a netstandard2.0 library. Repacking it requires resolving a reference to netstandard.dll, which I accomplished by adding _build/lib/nuget/netstandard.library/2.0.0/build/netstandard2.0/ref/ to ILRepack's Libs argument, since a copy of netstandard.dll is placed there by Nuget during restore.

The result of this is that the repack succeeds, but the netstandard.dll reference still needs to be resolved outside the EXE, which as far as I can tell would require installing mono-devel on Ubuntu, bloating the metadata tester container by ~300 MiB. This suggests to me that the copy of netstandard.dll that mono-devel installs is meant to be repacked, not referenced at runtime.

Presumably ILRepack would do this itself by default if it was a newer, more up to date tool, but this netstandard stuff is a bit newfangled for it, so we have to help it out.

Changes

  • ILRepack is updated from 2.0.18 to 2.0.27 to get better netstandard support (ILRepack's developer just started making releases a month ago after almost 5 years!)
  • The netstandard.library path is removed from ILRepack's Libs argument
  • The path to the netstandard facade DLL is added to the assemblyPaths. This is a ~90 KiB file that just tells Mono to look up the references in .NET Framework since that's what the repacked EXE is built for.

In my testing, this allows the metadata tester to run.

@HebaruSan HebaruSan added Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN Build Issues affecting the build system Cake Issues affecting Cake labels Feb 2, 2024
@HebaruSan HebaruSan merged commit 9b4d801 into KSP-CKAN:master Feb 2, 2024
8 checks passed
@HebaruSan HebaruSan deleted the fix/netstandard-facade branch February 2, 2024 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Build Issues affecting the build system Cake Issues affecting Cake Core (ckan.dll) Issues affecting the core part of CKAN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant