Format:.NET runtimeconfig.json and deps.json
| On this wiki | Facts · Code · Notes · Topics |
|---|
The JSON files beside a .NET Core / .NET 5+ program: <app>.runtimeconfig.json (framework name and version, runtime options, probing paths) and <app>.deps.json (target framework moniker, libraries with type/path/hash, the runtime and native assets per library, resources for satellite assemblies); also embedded in single-file bundles. Plus the .NET Framework app.config.
These files tell a reverser the target framework, whether the app is framework-dependent or self-contained, and which libraries it uses, before opening any assembly. They are read by the host (hostfxr / hostpolicy), not by managed code, so an edited copy changes how the program resolves assemblies.
<app>.deps.json
JSON with runtimeTarget (name of the chosen target), compilationOptions, targets and libraries. In targets, the key is a target framework moniker such as .NETCoreApp,Version=v2.1 (optionally /win-x64 for a runtime identifier), and below it each library Name/Version lists the assets it contributes: runtime (managed DLL paths relative to the library folder), native (native libraries), resources (satellite assemblies, keyed by path with a locale), and dependencies. In libraries each Name/Version has type (package, project, reference), serviceable, sha512 and path (the package folder, e.g. newtonsoft.json/11.0.2) (Fact:.NET runtimeconfig.json and deps.json/behavior/Probing). The host probes the library path plus asset path to find the file (Fact:.NET runtimeconfig.json and deps.json/behavior/Probing). If the app's own deps.json is missing, hostpolicy adds the app folder itself as a probe path and, in the non-libhost case, the DLLs found in it as local assemblies (dotnet/runtime at 66368e9, src/native/corehost/hostpolicy/deps_resolver.cpp, lines 550-557 and 838-847).
Identification (Unverified, from general knowledge): a self-contained app lists runtimepack.Microsoft.NETCore.App.Runtime.<rid> entries and the whole runtime's assemblies; a framework-dependent app lists only its own and NuGet assemblies.
<app>.runtimeconfig.json
JSON with a runtimeOptions object: tfm (e.g. net8.0), framework (name such as Microsoft.NETCore.App or Microsoft.WindowsDesktop.App, and version = the minimum), or includedFrameworks for self-contained apps, rollForward, and configProperties (runtime knobs such as System.GC.Server, System.Runtime.TieredPGO, System.Globalization.Invariant). additionalProbingPaths there (and in .runtimeconfig.dev.json) adds probing directories, highest priority first (Fact:.NET runtimeconfig.json and deps.json/behavior/Probing). The host parser reads exactly these names under runtimeOptions: configProperties, additionalProbingPaths, rollForward, tfm, framework / frameworks (each with name, version and optionally its own rollForward) and includedFrameworks; it is an error to give both framework(s) and includedFrameworks (dotnet/runtime at 66368e9, src/native/corehost/runtime_config.cpp, lines 68-250). Unverified: the individual configProperties keys such as System.GC.Server (they are read by the runtime, not by this parser).
Windows Desktop apps name Microsoft.WindowsDesktop.App (WPF, WinForms): then Format:BAML and Format:.NET resources (.resources) are likely.
In single-file bundles
A single-file app carries both files inside the bundle (file types 3 and 4; the bundle header stores their offsets): see Format:.NET single-file bundle.
.NET Framework: app.config
XML <exe name>.exe.config next to a .NET Framework program: <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup> names the target framework; <runtime><assemblyBinding><dependentAssembly><assemblyIdentity .../><bindingRedirect oldVersion=... newVersion=.../> redirects versions and <codeBase> points to assemblies. Unverified: from general knowledge, not read in a source for this page.
Host runtime properties
The host passes the resolved lists to the runtime as properties: APP_CONTEXT_DEPS_FILES, FX_DEPS_FILE, TRUSTED_PLATFORM_ASSEMBLIES, NATIVE_DLL_SEARCH_DIRECTORIES, PLATFORM_RESOURCE_ROOTS, PROBING_DIRECTORIES, BUNDLE_EXTRACTION_PATH (see dotnet/runtime docs/design/features/host-runtime-information.md).
Evidence & references
dotnet/runtime docs/design/features/host-probing.md, host-runtime-information.md.