You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using NSwag version 13.9.0 with a .NET 5-based build pipeline, publishing a single file trimmed executable fails where it was successful with .NET Core 3.1. We're able to work around this issue by removing trimming for now.
Below is the command line invocation and relevant error output from the trim process:
> dotnet publish Project.csproj -c Release -r linux-x64 /p:PublishSingleFile=true /p:PublishTrimmed=true -o /app/publish
ILLink : error IL1005: NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.<>c__DisplayClass5_0.<GetJsonSerializerSettings>b__0(): Error processing method 'NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.<>c__DisplayClass5_0.<GetJsonSerializerSettings>b__0()' in assembly 'NSwag.Generation.AspNetCore.dll' [D:\Workspaces\Project.csproj]
Mono.Linker.LinkerFatalErrorException: ILLink: error IL1005: NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.<>c__DisplayClass5_0.<GetJsonSerializerSettings>b__0(): Error processing method 'NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.<>c__DisplayClass5_0.<GetJsonSerializerSettings>b__0()' in assembly 'NSwag.Generation.AspNetCore.dll'
---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.GetValueNodeFromGenericArgument(TypeReference genericArgument)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.ProcessGenericArgumentDataFlow(GenericParameter genericParameter, TypeReference genericArgument, IMemberDefinition source)
at Mono.Linker.Steps.MarkStep.MarkGenericArgumentConstructors(IGenericInstance instance, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkTypeVisibleToReflection(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction, MethodDefinition method, Boolean& requiresReflectionMethodBodyScanner)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(41,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.
The text was updated successfully, but these errors were encountered:
@RicoSuter Doing some poking around, this appears to be related to known bug in linker (dotnet/linker#1559). This issue (dotnet/runtime#43222) notes some approaches for working around the linker bug.
Using NSwag version
13.9.0
with a .NET 5-based build pipeline, publishing a single file trimmed executable fails where it was successful with .NET Core 3.1. We're able to work around this issue by removing trimming for now.Below is the command line invocation and relevant error output from the trim process:
The text was updated successfully, but these errors were encountered: