Trimming Issues with .NET 7
With default trimming enabled
RUN dotnet publish -c Release -o /app -r linux-x64 --self-contained true /p:PublishTrimmed=true /p:PublishReadyToRun=true
An error is presented
System.InvalidOperationException: Compilation failures!
Runtime errors are present
CS0656: Missing compiler required member 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitOnCompleted' CS0656: Missing compiler required member 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AwaitOnCompleted'`
Was able to get the methods included by telling the trimmer to not trim them
Adding the following to my project file
<ItemGroup> <TrimmerRootDescriptor Include="MyRoots.xml" /> </ItemGroup>
Where MyRoots.xml contains
<linker> <assembly fullname="System.Runtime"> <type fullname="System.Runtime.CompilerServices.AsyncTaskMethod*" /> </assembly> </linker>
Seems like Marten or one of its dependencies has an issue where it's not really compatible with trimming.