diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/src/Microsoft.Extensions.DependencyModel.csproj b/src/libraries/Microsoft.Extensions.DependencyModel/src/Microsoft.Extensions.DependencyModel.csproj index ef308aebcfe16..01dd63044f788 100644 --- a/src/libraries/Microsoft.Extensions.DependencyModel/src/Microsoft.Extensions.DependencyModel.csproj +++ b/src/libraries/Microsoft.Extensions.DependencyModel/src/Microsoft.Extensions.DependencyModel.csproj @@ -3,10 +3,10 @@ $(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) true true - Abstractions for reading `.deps` files. + Provides abstractions for reading `.deps` files. When a .NET application is compiled, the SDK generates a JSON manifest file (`<ApplicationName>.deps.json`) that contains information about application dependencies. You can use `Microsoft.Extensions.DependencyModel` to read information from this manifest at run time. This is useful when you want to dynamically compile code (for example, using Roslyn Emit API) referencing the same dependencies as your main application. -Commonly Used Types: -Microsoft.Extensions.DependencyModel.DependencyContext +By default, the dependency manifest contains information about the application's target framework and runtime dependencies. Set the PreserveCompilationContext project property to `true` to additionally include information about reference assemblies used during compilation. + README.md @@ -14,6 +14,7 @@ Microsoft.Extensions.DependencyModel.DependencyContext Link="System\Numerics\Hashing\HashHelpers.cs" /> + diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/src/README.md b/src/libraries/Microsoft.Extensions.DependencyModel/src/README.md new file mode 100644 index 0000000000000..f4d4a485899eb --- /dev/null +++ b/src/libraries/Microsoft.Extensions.DependencyModel/src/README.md @@ -0,0 +1,37 @@ +## About + +Provides abstractions for reading `.deps` files. When a .NET application is compiled, the SDK generates a JSON manifest file (`.deps.json`) that contains information about application dependencies. You can use `Microsoft.Extensions.DependencyModel` to read information from this manifest at run time. This is useful when you want to dynamically compile code (for example, using Roslyn Emit API) referencing the same dependencies as your main application. + +By default, the dependency manifest contains information about the application's target framework and runtime dependencies. Set the [PreserveCompilationContext](https://docs.microsoft.com/dotnet/core/project-sdk/msbuild-props#preservecompilationcontext) project property to `true` to additionally include information about reference assemblies used during compilation. + +For more information, see the documentation: + +- [.deps.json file format](https://github.com/dotnet/sdk/blob/main/documentation/specs/runtime-configuration-file.md#appnamedepsjson) +- [Microsoft.Extensions.DependencyModel namespace](https://docs.microsoft.com/dotnet/api/microsoft.extensions.dependencymodel) +- [Microsoft.Extensions.DependencyModel.DependencyContext](https://docs.microsoft.com/dotnet/api/microsoft.extensions.dependencymodel.dependencycontext) + +## Example + +The following example shows how to display the list of assemblies used when compiling the current application. Include `true` in your project file to run this example. + +```cs +using System; +using Microsoft.Extensions.DependencyModel; + +class Program +{ + static void Main() + { + Console.WriteLine("Compilation libraries:"); + Console.WriteLine(); + + foreach (CompilationLibrary lib in DependencyContext.Default.CompileLibraries) + { + foreach (string path in lib.ResolveReferencePaths()) + { + Console.WriteLine(path); + } + } + } +} +``` diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/README.md b/src/libraries/System.Reflection.MetadataLoadContext/src/README.md index d3f1fab8e7f8a..7e351acc94fe7 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/README.md +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/README.md @@ -10,7 +10,7 @@ For more information, see the documentation: ## Example -The following example shows how print the list of types defined in an assembly. +The following example shows how to print the list of types defined in an assembly. ```cs using System;