marten icon indicating copy to clipboard operation
marten copied to clipboard

Trimming Issues with .NET 7

Open montanehamilton opened this issue 2 years ago • 0 comments

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.

montanehamilton avatar May 17 '23 15:05 montanehamilton