Repack netstandard facade in ckan.exe #4013
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 anetstandard2.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 thatmono-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
netstandard.library
path is removed from ILRepack's Libs argumentassemblyPaths
. 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.