Skip to content

NativeAOT: Custom runtime without AppContext class throw #77054

@kant2002

Description

@kant2002

Description

If you compile application with custom runtime where System.AppContext class is not defined, compiler crash

 System.AggregateException: One or more errors occurred. (Code generation failed for method '[S.P.CompilerGenerated]Internal.CompilerGenerated.<Module>.SetAppContextSwitches()')
   ---> ILCompiler.CodeGenerationFailedException: Code generation failed for method '[S.P.CompilerGenerated]Internal.CompilerGenerated.<Module>.SetAppContextSwitches()'
   ---> System.InvalidOperationException: Expected type 'System.AppContext' not found in module 'SeeSharpSnake'

Even if I apply suggestion from #63862 (comment) to the csproj file due to this line

<IlcArg Include="--appcontextswitch:RUNTIME_IDENTIFIER=$(RuntimeIdentifier)" />

workaround no longer working.

Reproduction Steps

Close code from this PR MichalStrehovsky/SeeSharpSnake#24
Apply #63862 (comment)

Expected behavior

Custom runtimes can be built using NativeAOT

Actual behavior

Currently it is blocked.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions