1

I have a library (dll). For some reason, when I compile, file .runtimeconfig.json is generated:

{
  "runtimeOptions": {
    "tfm": "net6.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "6.0.0"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "6.0.0"
      }
    ],
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false
    }
  }
}

Why is this file generated and why does it contain "System.Reflection.Metadata.MetadataUpdater.IsSupported": false? This is a non runable library, so why is a .runtimeconfig.json generated?

osexpert
  • 485
  • 1
  • 6
  • 18
  • It states whether [ApplyUpdate()](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.metadata.metadataupdater.applyupdate?view=net-7.0#system-reflection-metadata-metadataupdater-applyupdate(system-reflection-assembly-system-readonlyspan((system-byte))-system-readonlyspan((system-byte))-system-readonlyspan((system-byte)))) is supported. High odds that this is related to the new [hot reload feature](https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/). – Hans Passant Nov 24 '22 at 20:38

2 Answers2

0

Generating the config file is controlled by GenerateRuntimeConfigurationFiles setting in .csproj: probably is set to true. Please see this section of Microsoft help regarding generating and purpose of runtimeconfig.json. And here is the concise description of the property metadataupdater.issupported. More detailed explanation also here: What is the purpose of msbuild's GenerateRuntimeConfigurationFiles?

Angel Dinev
  • 399
  • 4
  • 13
  • GenerateRuntimeConfigurationFiles is not set anywhere. – osexpert Nov 25 '22 at 21:02
  • A freshly build empty templated console app creates .runtimeconfig.json in bin\Debug|Release folder. It's created by default and disabling the generation with the above mentioned flag set to **false**, triggered the following error from the runtime: `A fatal error was encountered...Failed to run as a self-contained app. The application was run as a self-contained app because '.runtimeconfig.json' was not found. If this should be a framework-dependent app, add the .runtimeconfig.json file and specify the appropriate framework.`. Self-contained apps require a runtime. Good luck! – Angel Dinev Nov 27 '22 at 12:35
  • "A freshly build empty templated console app creates" Yes, but in my case its a library, and they should not, in theory, have runtimeconfig generated – osexpert Nov 29 '22 at 22:11
0

The runtime config file as far as I know is only created for executables and tells the dotnet runtime what runtime version to use and what frameworks (e.g. aspnet core) to include as these are bundled with the runtime. As dotnet executables in most cases however are dll files aswell with an executable as a "starter" it is possible you might have both as an output.

See also https://github.com/dotnet/runtime/blob/9d6396deb02161f5ee47af72ccac52c2e1bae458/docs/design/features/sharedfx-lookup.md#framework-search-and-rolling-forward

Does your csproj by any chance include <OutputType>Exe</OutputType> and a main somewhere?

The System.Reflection.Metadata.MetadataUpdater.IsSupported part as far as I can see tells the runtime that the app you're running doesn't support Metadata Updates (I assume that has something to do with hot reload). This gets added when the app is build in release mode.

Wolfspirit
  • 728
  • 7
  • 9