I have an F# project that I build this way:
dotnet publish --nologo -r osx-x64 -c Release --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:PublishReadyToRun=true
and I get pages of this:
RUNREADYTORUNCOMPILER : warning : Could not load type 'System.Resources.IResourceWriter' from assembly 'System.Text.RegularExpressions, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. while resolving 0x10000ce - System.Resources.IResourceWriter. [/Users/thomas/Projects/test/test.fsproj]
RUNREADYTORUNCOMPILER : warning : Could not load type 'System.Text.Encodings.Web.JavaScriptEncoder' from assembly 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. while resolving 0x2000045 - System.Text.Json.JsonWriterOptions. [/Users/thomas/Projects/test/test.fsproj]
RUNREADYTORUNCOMPILER : warning : Could not load type 'System.Text.Encodings.Web.JavaScriptEncoder' from assembly 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. while resolving 0x2000046 - System.Text.Json.Utf8JsonWriter. [/Users/thomas/Projects/test/test.fsproj]
RUNREADYTORUNCOMPILER : warning : Could not load type 'System.Text.Encodings.Web.JavaScriptEncoder' from assembly 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. while resolving 0x1000011 - System.Text.Encodings.Web.JavaScriptEncoder. [/Users/thomas/Projects/test/test.fsproj]
RUNREADYTORUNCOMPILER : warning : Could not load type 'System.Text.Encodings.Web.TextEncoder' from assembly 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. while resolving 0x10000ad - System.Text.Encodings.Web.TextEncoder. [/Users/thomas/Projects/test/test.fsproj]
RUNREADYTORUNCOMPILER : warning : Could not load type 'System.Text.Encodings.Web.TextEncoder' from assembly 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. while resolving 0xa00023c - System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8. [/Users/thomas/Projects/test/test.fsproj]
RUNREADYTORUNCOMPILER : warning : Could not load type 'System.Text.Encodings.Web.TextEncoder' from assembly 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. while resolving 0xa00023f - System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncode. [/Users/thomas/Projects/test/test.fsproj]
What does this error mean?
I have another project I build with the exact same command line without any problem.
If I remove the single file attribute, then it will build properly.
How can I troubleshoot this? The error message doesn't really explain what's going on.
Adding this to the project file to fix JavaScriptEncoder:
<TrimmerRootAssembly Include="System.Text.Encodings.Web" />
And this for IResourceWriter:
<TrimmerRootAssembly Include="System.Resources.Writer" />
ReadyToRun sometimes needs help (or it’s just buggy) on what to include. You can read more here.