diff --git a/.openpublishing.redirection.json b/.openpublishing.redirection.json index acaf9ecc031d..f9ee5ae2da5e 100644 --- a/.openpublishing.redirection.json +++ b/.openpublishing.redirection.json @@ -177,7 +177,7 @@ }, { "source_path": "aspnetcore/hosting/ihostingstartup.md", - "redirect_url": "/aspnet/core/fundamentals/configuration/platform-specific-configuration", + "redirect_url": "/aspnet/core/fundamentals/host/platform-specific-configuration", "redirect_document_id": false }, { @@ -307,7 +307,7 @@ }, { "source_path": "aspnetcore/host-and-deploy/ihostingstartup.md", - "redirect_url": "/aspnet/core/fundamentals/configuration/platform-specific-configuration", + "redirect_url": "/aspnet/core/fundamentals/host/platform-specific-configuration", "redirect_document_id": false }, { @@ -337,7 +337,7 @@ }, { "source_path": "aspnetcore/host-and-deploy/platform-specific-configuration.md", - "redirect_url": "/aspnet/core/fundamentals/configuration/platform-specific-configuration", + "redirect_url": "/aspnet/core/fundamentals/host/platform-specific-configuration", "redirect_document_id": false }, { @@ -450,10 +450,15 @@ "redirect_url": "/aspnet/core/razor-pages/upload-files", "redirect_document_id": false }, - { + { "source_path": "aspnet/mvc/overview/getting-started/introduction/sample/code-location.md", "redirect_url": "/aspnet/mvc/overview/getting-started/introduction/index", "redirect_document_id": false + }, + { + "source_path": "aspnetcore/fundamentals/configuration/platform-specific-configuration.md", + "redirect_url": "/aspnet/core/fundamentals/host/platform-specific-configuration", + "redirect_document_id": false } ] } diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration.md b/aspnetcore/fundamentals/configuration/platform-specific-configuration.md deleted file mode 100644 index a075e70aa89d..000000000000 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -title: Enhance an app from an external assembly in ASP.NET Core with IHostingStartup -author: guardrex -description: Discover how to enhance an ASP.NET Core app from an external assembly using an IHostingStartup implementation. -monikerRange: '>= aspnetcore-2.0' -ms.author: riande -ms.custom: mvc -ms.date: 12/07/2017 -uid: fundamentals/configuration/platform-specific-configuration ---- -# Enhance an app from an external assembly in ASP.NET Core with IHostingStartup - -By [Luke Latham](https://github.com/guardrex) - -An [IHostingStartup](/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup) implementation allows adding enhancements to an app at startup from an external assembly outside of the app's `Startup` class. For example, an external tooling library can use an `IHostingStartup` implementation to provide additional configuration providers or services to an app. `IHostingStartup` *is available in ASP.NET Core 2.0 and later.* - -[View or download sample code](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/) ([how to download](xref:tutorials/index#how-to-download-a-sample)) - -## Discover loaded hosting startup assemblies - -To discover hosting startup assemblies loaded by the app or by libraries, enable logging and check the application logs. Errors that occur when loading assemblies are logged. Loaded hosting startup assemblies are logged at the Debug level, and all errors are logged. - -The sample app reads the [HostingStartupAssembliesKey](/dotnet/api/microsoft.aspnetcore.hosting.webhostdefaults.hostingstartupassemblieskey) into a `string` array and displays the result in the app's Index page: - -[!code-csharp[](platform-specific-configuration/sample/HostingStartupSample/Pages/Index.cshtml.cs?name=snippet1&highlight=14-16)] - -## Disable automatic loading of hosting startup assemblies - -There are two ways to disable the automatic loading of hosting startup assemblies: - -* Set the [Prevent Hosting Startup](xref:fundamentals/host/web-host#prevent-hosting-startup) host configuration setting. -* Set the `ASPNETCORE_PREVENTHOSTINGSTARTUP` environment variable. - -When either the host setting or the environment variable is set to `true` or `1`, hosting startup assemblies aren't automatically loaded. If both are set, the host setting controls the behavior. - -Disabling hosting startup assemblies using the host setting or environment variable disables them globally and may disable several characteristics of an app. It isn't currently possible to selectively disable a hosting startup assembly added by a library unless the library offers its own configuration option. A future release will offer the ability to selectively disable hosting startup assemblies (see [GitHub issue aspnet/Hosting #1243](https://github.com/aspnet/Hosting/pull/1243)). - -## Implement IHostingStartup - -### Create the assembly - -An `IHostingStartup` enhancement is deployed as an assembly based on a console app without an entry point. The assembly references the [Microsoft.AspNetCore.Hosting.Abstractions](https://www.nuget.org/packages/Microsoft.AspNetCore.Hosting.Abstractions/) package: - -[!code-xml[](platform-specific-configuration/snapshot_sample/StartupEnhancement.csproj)] - -A [HostingStartup](/dotnet/api/microsoft.aspnetcore.hosting.hostingstartupattribute) attribute identifies a class as an implementation of `IHostingStartup` for loading and execution when building the [IWebHost](/dotnet/api/microsoft.aspnetcore.hosting.iwebhost). In the following example, the namespace is `StartupEnhancement`, and the class is `StartupEnhancementHostingStartup`: - -[!code-csharp[](platform-specific-configuration/snapshot_sample/StartupEnhancement.cs?name=snippet1)] - -A class implements `IHostingStartup`. The class's [Configure](/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup.configure) method uses an [IWebHostBuilder](/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) to add enhancements to an app. `IHostingStartup.Configure` in the hosting startup assembly is called by the runtime before `Startup.Configure` in user code, which allows user code to overwrite any configruation provided by the hosting startup assembly. - -[!code-csharp[](platform-specific-configuration/snapshot_sample/StartupEnhancement.cs?name=snippet2&highlight=3,5)] - -When building an `IHostingStartup` project, the dependencies file (*\*.deps.json*) sets the `runtime` location of the assembly to the *bin* folder: - -[!code-json[](platform-specific-configuration/snapshot_sample/StartupEnhancement1.deps.json?range=2-13&highlight=8)] - -Only part of the file is shown. The assembly name in the example is `StartupEnhancement`. - -### Update the dependencies file - -The runtime location is specified in the *\*.deps.json* file. To active the enhancement, the `runtime` element must specify the location of the enhancement's runtime assembly. Prefix the `runtime` location with `lib//`: - -[!code-json[](platform-specific-configuration/snapshot_sample/StartupEnhancement2.deps.json?range=2-13&highlight=8)] - -In the sample app, modification of the *\*.deps.json* file is performed by a [PowerShell](/powershell/scripting/powershell-scripting) script. The PowerShell script is automatically triggered by a build target in the project file. - -### Enhancement activation - -**Place the assembly file** - -The `IHostingStartup` implementation's assembly file must be *bin*-deployed in the app or placed in the [runtime store](/dotnet/core/deploying/runtime-store): - -For per-user use, place the assembly in the user profile's runtime store at: - -``` -\Users\\.dotnet\store\x64\\\\lib\\ -``` - -For global use, place the assembly in the .NET Core installation's runtime store: - -``` -\Program Files\dotnet\store\x64\\\\lib\\ -``` - -When deploying the assembly to the runtime store, the symbols file may be deployed as well but isn't required for the enhancement to work. - -**Place the dependencies file** - -The implementation's *\*.deps.json* file must be in an accessible location. - -For per-user use, place the file in the `additonalDeps` folder of the user profile's `.dotnet` settings: - -``` -\Users\\.dotnet\x64\additionalDeps\\shared\Microsoft.NETCore.App\\ -``` - -For global use, place the file in the `additonalDeps` folder of the .NET Core installation: - -``` -\Program Files\dotnet\additionalDeps\\shared\Microsoft.NETCore.App\\ -``` - -The shared framework version reflects the version of the shared runtime that the target app uses. The shared runtime is shown in the *\*.runtimeconfig.json* file. In the sample app, the shared runtime is specified in the *HostingStartupSample.runtimeconfig.json* file. - -**Set environment variables** - -Set the following environment variables in the context of the app that uses the enhancement. - -ASPNETCORE_HOSTINGSTARTUPASSEMBLIES - -Only hosting startup assemblies are scanned for the `HostingStartupAttribute`. The assembly name of the implementation is provided in this environment variable. The sample app sets this value to `StartupDiagnostics`. - -The value can also be set using the [Hosting Startup Assemblies](xref:fundamentals/host/web-host#hosting-startup-assemblies) host configuration setting. - -When multiple hosting startup assembles are present, their [Configure](/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup.configure) methods are executed in the order that the assemblies are listed. - -DOTNET_ADDITIONAL_DEPS - -The location of the implementation's *\*.deps.json* file. - -If the file is placed in the user profile's *.dotnet* folder for per-user use: - -``` -\Users\\.dotnet\x64\additionalDeps\ -``` - -If the file is placed in the .NET Core installation for global use, provide the full path to the file: - -``` -\Program Files\dotnet\additionalDeps\\shared\Microsoft.NETCore.App\\.deps.json -``` - -The sample app sets this value to: - -``` -%UserProfile%\.dotnet\x64\additionalDeps\StartupDiagnostics\ -``` - -For examples of how to set environment variables for various operating systems, see [Use multiple environments](xref:fundamentals/environments). - -## Sample app - -The [sample app](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/) ([how to download](xref:tutorials/index#how-to-download-a-sample)) uses `IHostingStartup` to create a diagnostics tool. The tool adds two middlewares to the app at startup that provide diagnostic information: - -* Registered services -* Address: scheme, host, path base, path, query string -* Connection: remote IP, remote port, local IP, local port, client certificate -* Request headers -* Environment variables - -To run the sample: - -1. The Startup Diagnostic project uses [PowerShell](/powershell/scripting/powershell-scripting) to modify its *StartupDiagnostics.deps.json* file. PowerShell is installed by default on Windows OS starting with Windows 7 SP1 and Windows Server 2008 R2 SP1. To obtain PowerShell on other platforms, see [Installing Windows PowerShell](/powershell/scripting/setup/installing-windows-powershell). -2. Build the Startup Diagnostic project. A build target in the project file: - * Moves the assembly and symbols files to the user profile's runtime store. - * Triggers the PowerShell script to modify the *StartupDiagnostics.deps.json* file. - * Moves the *StartupDiagnostics.deps.json* file to the user profile's `additionalDeps` folder. -3. Set the environment variables: - * `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES`: `StartupDiagnostics` - * `DOTNET_ADDITIONAL_DEPS`: `%UserProfile%\.dotnet\x64\additionalDeps\StartupDiagnostics\` -4. Run the sample app. -5. Request the `/services` endpoint to see the app's registered services. Request the `/diag` endpoint to see the diagnostic information. diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/HostingStartupSample.csproj b/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/HostingStartupSample.csproj deleted file mode 100644 index dfcbfaf32488..000000000000 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/HostingStartupSample.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - netcoreapp2.1 - - - - - - - diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Index.cshtml b/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Index.cshtml deleted file mode 100644 index e45d2f636d27..000000000000 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Index.cshtml +++ /dev/null @@ -1,60 +0,0 @@ -@page -@model IndexModel -@{ - ViewData["Title"] = "Hosting Startup Sample"; -} - -

@ViewData["Title"]

- -
-
-
-
-

Startup Diagnostics Instructions

-
-
-

Services

-

- When the IHostingStartup implementation's Configure method executes, a factory is registered that implements a method to obtain the app's service collection descriptors. An implementation of IStartupFilter branches the request pipeline for the path /services, which executes a terminal middleware delegate. The delegate produces a webpage showing the app's services using the factory's GetServices method. -

-

- To see the services in the service collection of the app, request the /services endpoint from the running app. -

-

Connection Information

-

- The implementation of IStartupFilter also registers a middleware, DiagnosticMiddleware, that outputs diagonistic information on the: -

    -
  • Request
  • -
  • Connection
  • -
  • Headers
  • -
  • Environment variables
  • -
-

-

- To see the diagnostic information from the app, request the /diag endpoint from the running app. -

-
-
-
-
- -
-
-
-
-

Loaded Hosting Startup Assemblies

-
-
-

Assemblies

-
    - @foreach (var assembly in Model.LoadedHostingStartupAssemblies) - { -
  • @assembly
  • - } -
-
-
-
-
- - diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Index.cshtml.cs b/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Index.cshtml.cs deleted file mode 100644 index de148d363902..000000000000 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Index.cshtml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Configuration; - -namespace HostingStartupSample.Pages -{ - #region snippet1 - public class IndexModel : PageModel - { - private readonly IConfiguration _config; - - public IndexModel(IConfiguration config) - { - _config = config; - } - - public string[] LoadedHostingStartupAssemblies { get; private set; } - - public void OnGet() - { - LoadedHostingStartupAssemblies = - _config[WebHostDefaults.HostingStartupAssembliesKey] - .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ?? new string[0]; - } - } - #endregion -} diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/_ViewImports.cshtml b/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/_ViewImports.cshtml deleted file mode 100644 index 68d8b8776ffe..000000000000 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/_ViewImports.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using HostingStartupSample -@namespace HostingStartupSample.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/StartupDiagnostics.csproj b/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/StartupDiagnostics.csproj deleted file mode 100644 index 4a886cbf7a02..000000000000 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/StartupDiagnostics.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - - netcoreapp2.1 - 2.1.0 - 1.0.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/aspnetcore/fundamentals/host/index.md b/aspnetcore/fundamentals/host/index.md index 30e1e95c9b14..2f63cbeff15f 100644 --- a/aspnetcore/fundamentals/host/index.md +++ b/aspnetcore/fundamentals/host/index.md @@ -4,7 +4,7 @@ author: guardrex description: Learn about the ASP.NET Core Web Host and .NET Generic Host, which are responsible for app startup and lifetime management. ms.author: riande ms.custom: mvc -ms.date: 05/16/2018 +ms.date: 08/28/2018 uid: fundamentals/host/index --- # Host in ASP.NET Core @@ -14,4 +14,10 @@ uid: fundamentals/host/index * [Web Host](xref:fundamentals/host/web-host) – Suitable for hosting web apps. * [Generic Host](xref:fundamentals/host/generic-host) (ASP.NET Core 2.1 or later) – Suitable for hosting non-web apps (for example, apps that run background tasks). In a future release, the Generic Host will be suitable for hosting any kind of app, including web apps. The Generic Host will eventually replace the Web Host. -For hosting ASP.NET Core *web apps*, developers should use the Web Host based on [IWebHostBuilder](/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder). For hosting *non-web apps*, developers should use the Generic Host based on [HostBuilder](/dotnet/api/microsoft.extensions.hosting.hostbuilder). +For hosting ASP.NET Core *web apps*, developers should use the Web Host based on . For hosting *non-web apps*, developers should use the Generic Host based on . + + +Learn how to implement background tasks with hosted services in ASP.NET Core. + + +Discover how to enhance an ASP.NET Core app from a referenced or unreferenced assembly using an implementation. diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration.md b/aspnetcore/fundamentals/host/platform-specific-configuration.md new file mode 100644 index 000000000000..4ff2179e66b8 --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration.md @@ -0,0 +1,444 @@ +--- +title: Enhance an app from an external assembly in ASP.NET Core with IHostingStartup +author: guardrex +description: Discover how to enhance an ASP.NET Core app from an external assembly using an IHostingStartup implementation. +monikerRange: '>= aspnetcore-2.0' +ms.author: riande +ms.custom: mvc +ms.date: 08/13/2018 +uid: fundamentals/configuration/platform-specific-configuration +--- +# Enhance an app from an external assembly in ASP.NET Core with IHostingStartup + +By [Luke Latham](https://github.com/guardrex) + +An [IHostingStartup](/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup) (hosting startup) implementation adds enhancements to an app at startup from an external assembly. For example, an external library can use a hosting startup implementation to provide additional configuration providers or services to an app. `IHostingStartup` *is available in ASP.NET Core 2.0 or later.* + +[View or download sample code](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/host/platform-specific-configuration/samples/) ([how to download](xref:tutorials/index#how-to-download-a-sample)) + +## HostingStartup attribute + +A [HostingStartup](/dotnet/api/microsoft.aspnetcore.hosting.hostingstartupattribute) attribute indicates the presence of a hosting startup assembly to activate at runtime. + +The entry assembly or the assembly containing the `Startup` class is automatically scanned for the `HostingStartup` attribute. The list of assemblies to search for `HostingStartup` attributes is loaded at runtime from configuration in the [WebHostDefaults.HostingStartupAssembliesKey](/dotnet/api/microsoft.aspnetcore.hosting.webhostdefaults.hostingstartupassemblieskey). The list of assemblies to exclude from discovery is loaded from the [WebHostDefaults.HostingStartupExcludeAssembliesKey](/dotnet/api/microsoft.aspnetcore.hosting.webhostdefaults.hostingstartupexcludeassemblieskey). For more information, see [Web Host: Hosting Startup Assemblies](xref:fundamentals/host/web-host#hosting-startup-assemblies) and [Web Host: Hosting Startup Exclude Assemblies](xref:fundamentals/host/web-host#hosting-startup-exclude-assemblies). + +In the following example, the namespace of the hosting startup assembly is `StartupEnhancement`. The class containing the hosting startup code is `StartupEnhancementHostingStartup`: + +[!code-csharp[](platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.cs?name=snippet1)] + +The `HostingStartup` attribute is typically located in the hosting startup assembly's `IHostingStartup` implementation class file. + +## Discover loaded hosting startup assemblies + +To discover loaded hosting startup assemblies, enable logging and check the app's logs. Errors that occur when loading assemblies are logged. Loaded hosting startup assemblies are logged at the Debug level, and all errors are logged. + +## Disable automatic loading of hosting startup assemblies + +::: moniker range=">= aspnetcore-2.1" + +To disable automatic loading of hosting startup assemblies, use one of the following approaches: + +* To prevent all hosting startup assemblies from loading, set one of the following to `true` or `1`: + * [Prevent Hosting Startup](xref:fundamentals/host/web-host#prevent-hosting-startup) host configuration setting. + * `ASPNETCORE_PREVENTHOSTINGSTARTUP` environment variable. +* To prevent specific hosting startup assemblies from loading, set one of the following to a semicolon-delimited string of hosting startup assemblies to exclude at startup: + * [Hosting Startup Exclude Assemblies](xref:fundamentals/host/web-host#hosting-startup-exclude-assemblies) host configuration setting. + * `ASPNETCORE_HOSTINGSTARTUPEXCLUDEASSEMBLIES` environment variable. + +::: moniker-end + +::: moniker range="= aspnetcore-2.0" + +To disable automatic loading of hosting startup assemblies, set one of the following to `true` or `1`: + +* [Prevent Hosting Startup](xref:fundamentals/host/web-host#prevent-hosting-startup) host configuration setting. +* `ASPNETCORE_PREVENTHOSTINGSTARTUP` environment variable. + +::: moniker-end + +If both the host configuration setting and the environment variable are set, the host setting controls the behavior. + +Disabling hosting startup assemblies using the host setting or environment variable disables the assembly globally and may disable several characteristics of an app. + +## Project + +Create a hosting startup with either of the following project types: + +* [Class library](#class-library) +* [Console app without an entry point](#console-app-without-an-entry-point) + +### Class library + +A hosting startup enhancement can be provided in a class library. The library contains a `HostingStartup` attribute. + +The [sample code](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/host/platform-specific-configuration/samples/) includes a Razor Pages app, *HostingStartupApp*, and a class library, *HostingStartupLibrary*. The class library: + +* Contains a hosting startup class, `ServiceKeyInjection`, which implements `IHostingStartup`. `ServiceKeyInjection` adds a pair of service strings to the app's configuration using the in-memory configuration provider ([AddInMemoryCollection](/dotnet/api/microsoft.extensions.configuration.memoryconfigurationbuilderextensions.addinmemorycollection)). +* Includes a `HostingStartup` attribute that identifies the hosting startup's namespace and class. + +The `ServiceKeyInjection` class's [Configure](/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup.configure) method uses an [IWebHostBuilder](/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) to add enhancements to an app. `IHostingStartup.Configure` in the hosting startup assembly is called by the runtime before `Startup.Configure` in user code, which allows user code to overwrite any configuration provided by the hosting startup assembly. + +*HostingStartupLibrary/ServiceKeyInjection.cs*: + +[!code-csharp[](platform-specific-configuration/samples/2.x/HostingStartupLibrary/ServiceKeyInjection.cs?name=snippet1)] + +The app's Index page reads and renders the configuration values for the two keys set by the class library's hosting startup assembly: + +*HostingStartupApp/Pages/Index.cshtml.cs*: + +[!code-csharp[](platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml.cs?name=snippet1&highlight=5-6,11-12)] + +The [sample code](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/host/platform-specific-configuration/samples/) also includes a NuGet package project that provides a separate hosting startup, *HostingStartupPackage*. The package has the same characteristics of the class library described earlier. The package: + +* Contains a hosting startup class, `ServiceKeyInjection`, which implements `IHostingStartup`. `ServiceKeyInjection` adds a pair of service strings to the app's configuration. +* Includes a `HostingStartup` attribute. + +*HostingStartupPackage/ServiceKeyInjection.cs*: + +[!code-csharp[](platform-specific-configuration/samples/2.x/HostingStartupPackage/ServiceKeyInjection.cs?name=snippet1)] + +The app's Index page reads and renders the configuration values for the two keys set by the package's hosting startup assembly: + +*HostingStartupApp/Pages/Index.cshtml.cs*: + +[!code-csharp[](platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml.cs?name=snippet1&highlight=7-8,13-14)] + +### Console app without an entry point + +*This approach is only available for .NET Core apps, not .NET Framework.* + +A dynamic hosting startup enhancement that doesn't require a compile-time reference for activation can be provided in a console app without an entry point. The app contains a `HostingStartup` attribute. To create a dynamic hosting startup: + +1. An implementation library is created from the class that contains the `IHostingStartup` implementation. The implementation library is treated as a normal package. +1. A console app without an entry point references the implementation library package. A console app is used because: + * A dependencies file is a runnable app asset, so a library can't furnish a dependencies file. + * A library can't be added directly to the [runtime package store](/dotnet/core/deploying/runtime-store), which requires a runnable project that targets the shared runtime. +1. The console app is published to obtain the hosting startup's dependencies. A consequence of publishing the console app is that unused dependencies are trimmed from the dependencies file. +1. The app and its dependencies file is placed into the runtime package store. To discover the hosting startup assembly and its dependencies file, they're referenced in a pair of environment variables. + +The console app references the [Microsoft.AspNetCore.Hosting.Abstractions](https://www.nuget.org/packages/Microsoft.AspNetCore.Hosting.Abstractions/) package: + +[!code-xml[](platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.csproj)] + +A [HostingStartup](/dotnet/api/microsoft.aspnetcore.hosting.hostingstartupattribute) attribute identifies a class as an implementation of `IHostingStartup` for loading and execution when building the [IWebHost](/dotnet/api/microsoft.aspnetcore.hosting.iwebhost). In the following example, the namespace is `StartupEnhancement`, and the class is `StartupEnhancementHostingStartup`: + +[!code-csharp[](platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.cs?name=snippet1)] + +A class implements `IHostingStartup`. The class's [Configure](/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup.configure) method uses an [IWebHostBuilder](/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder) to add enhancements to an app. `IHostingStartup.Configure` in the hosting startup assembly is called by the runtime before `Startup.Configure` in user code, which allows user code to overwrite any configuration provided by the hosting startup assembly. + +[!code-csharp[](platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.cs?name=snippet2&highlight=3,5)] + +When building an `IHostingStartup` project, the dependencies file (*\*.deps.json*) sets the `runtime` location of the assembly to the *bin* folder: + +[!code-json[](platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement1.deps.json?range=2-13&highlight=8)] + +Only part of the file is shown. The assembly name in the example is `StartupEnhancement`. + +## Specify the hosting startup assembly + +For either a class library- or console app-supplied hosting startup, specify the hosting startup assembly's name in the `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES` environment variable. The environment variable is a semicolon-delimited list of assemblies. + +Only hosting startup assemblies are scanned for the `HostingStartup` attribute. For the sample app, *HostingStartupApp*, to discover the hosting startups described earlier, the environment variable is set to the following value: + +``` +HostingStartupLibrary;HostingStartupPackage;StartupDiagnostics +``` + +A hosting startup assembly can also be set using the [Hosting Startup Assemblies](xref:fundamentals/host/web-host#hosting-startup-assemblies) host configuration setting. + +When multiple hosting startup assembles are present, their [Configure](/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup.configure) methods are executed in the order that the assemblies are listed. + +## Activation + +Options for hosting startup activation are: + +* [Runtime store](#runtime-store) – Activation doesn't require a compile-time reference for activation. The sample app places the hosting startup assembly and dependencies files into a folder, *deployment*, to facilitate deployment of the hosting startup in a multimachine environment. The *deployment* folder also includes a PowerShell script that creates or modifies environment variables on the deployment system to enable the hosting startup. +* Compile-time reference required for activation + * [NuGet package](#nuget-package) + * [Project bin folder](#project-bin-folder) + +### Runtime store + +The hosting startup implementation is placed in the [runtime store](/dotnet/core/deploying/runtime-store). A compile-time reference to the assembly isn't required by the enhanced app. + +After the hosting startup is built, the hosting startup's project file serves as the manifest file for the [dotnet store](/dotnet/core/tools/dotnet-store) command. + +```console +dotnet store --manifest --runtime +``` + +This command places the hosting startup assembly and other dependencies that aren't part of the shared framework in the user profile's runtime store at: + +# [Windows](#tab/windows) + +``` +%USERPROFILE%\.dotnet\store\x64\\\\lib\\ +``` + +# [macOS](#tab/macos) + +``` +/Users//.dotnet/store/x64////lib// +``` + +# [Linux](#tab/linux) + +``` +/Users//.dotnet/store/x64////lib// +``` + +--- + +If you desire to place the assembly and dependencies for global use, add the `-o|--output` option to the `dotnet store` command with the following path: + +# [Windows](#tab/windows) + +``` +%PROGRAMFILES%\dotnet\store\x64\\\\lib\\ +``` + +# [macOS](#tab/macos) + +``` +/usr/local/share/dotnet/store/x64////lib// +``` + +# [Linux](#tab/linux) + +``` +/usr/local/share/dotnet/store/x64////lib// +``` + +--- + +**Modify and place the hosting startup's dependencies file** + +The runtime location is specified in the *\*.deps.json* file. To activate the enhancement, the `runtime` element must specify the location of the enhancement's runtime assembly. Prefix the `runtime` location with `lib//`: + +[!code-json[](platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement2.deps.json?range=2-13&highlight=8)] + +In the sample code (*StartupDiagnostics* project), modification of the *\*.deps.json* file is performed by a [PowerShell](/powershell/scripting/powershell-scripting) script. The PowerShell script is automatically triggered by a build target in the project file. + +The implementation's *\*.deps.json* file must be in an accessible location. + +For per-user use, place the file in the *additonalDeps* folder of the user profile's `.dotnet` settings: + +# [Windows](#tab/windows) + +``` +%USERPROFILE%\.dotnet\x64\additionalDeps\\shared\Microsoft.NETCore.App\\ +``` + +# [macOS](#tab/macos) + +``` +/Users//.dotnet/x64/additionalDeps//shared/Microsoft.NETCore.App// +``` + +# [Linux](#tab/linux) + +``` +/Users//.dotnet/x64/additionalDeps//shared/Microsoft.NETCore.App// +``` + +--- + +For global use, place the file in the *additonalDeps* folder of the .NET Core installation: + +# [Windows](#tab/windows) + +``` +%PROGRAMFILES%\dotnet\additionalDeps\\shared\Microsoft.NETCore.App\\ +``` + +# [macOS](#tab/macos) + +``` +/usr/local/share/dotnet/additionalDeps//shared/Microsoft.NETCore.App// +``` + +# [Linux](#tab/linux) + +``` +/usr/local/share/dotnet/additionalDeps//shared/Microsoft.NETCore.App// +``` + +--- + +The shared framework version reflects the version of the shared runtime that the target app uses. The shared runtime is shown in the *\*.runtimeconfig.json* file. In the sample app (*HostingStartupApp*), the shared runtime is specified in the *HostingStartupApp.runtimeconfig.json* file. + +**List the hosting startup's dependencies file** + +The location of the implementation's *\*.deps.json* file is listed in the `DOTNET_ADDITIONAL_DEPS` environment variable. + +If the file is placed in the user profile's *.dotnet* folder, set the environment variable's value to: + +# [Windows](#tab/windows) + +``` +%USERPROFILE%\.dotnet\x64\additionalDeps\ +``` + +# [macOS](#tab/macos) + +``` +/Users//.dotnet/x64/additionalDeps/ +``` + +# [Linux](#tab/linux) + +``` +/Users//.dotnet/x64/additionalDeps/ +``` + +--- + +If the file is placed in the .NET Core installation for global use, provide the full path to the file: + +# [Windows](#tab/windows) + +``` +%PROGRAMFILES%\dotnet\additionalDeps\\shared\Microsoft.NETCore.App\\.deps.json +``` + +# [macOS](#tab/macos) + +``` +/usr/local/share/dotnet/additionalDeps//shared/Microsoft.NETCore.App//.deps.json +``` + +# [Linux](#tab/linux) + +``` +/usr/local/share/dotnet/additionalDeps//shared/Microsoft.NETCore.App//.deps.json +``` + +--- + +For the sample app (*HostingStartupApp*) to find the dependencies file (*HostingStartupApp.runtimeconfig.json*), the dependencies file is placed in the user's profile. + +# [Windows](#tab/windows) + +Set the `DOTNET_ADDITIONAL_DEPS` environment variable to the following value: + +``` +%UserProfile%\.dotnet\x64\additionalDeps\StartupDiagnostics\ +``` + +# [macOS](#tab/macos) + +Set the `DOTNET_ADDITIONAL_DEPS` environment variable to the following value: + +``` +/Users//.dotnet/x64/additionalDeps/StartupDiagnostics/ +``` + +# [Linux](#tab/linux) + +Set the `DOTNET_ADDITIONAL_DEPS` environment variable to the following value: + +``` +/Users//.dotnet/x64/additionalDeps/StartupDiagnostics/ +``` + +--- + +For examples of how to set environment variables for various operating systems, see [Use multiple environments](xref:fundamentals/environments). + +**Deployment** + +To facilitate the deployment of a hosting startup in a multimachine environment, the sample app creates a *deployment* folder in published output that contains: + +* The hosting startup assembly. +* The hosting startup dependencies file. +* A PowerShell script that creates or modifies the `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES` and `DOTNET_ADDITIONAL_DEPS` to support the activation of the hosting startup. Run the script from an administrative PowerShell command prompt on the deployment system. + +### NuGet package + +A hosting startup enhancement can be provided in a NuGet package. The package has a `HostingStartup` attribute. The hosting startup types provided by the package are made available to the app using either of the following approaches: + +* The enhanced app's project file makes a package reference for the hosting startup in the app's project file (a compile-time reference). With the compile-time reference in place, the hosting startup assembly and all of its dependencies are incorporated into the app's dependency file (*\*.deps.json*). This approach applies to a hosting startup assembly package published to [nuget.org](https://www.nuget.org/). +* The hosting startup's dependencies file is made available to the enhanced app as described in the [Runtime store](#runtime-store) section (without a compile-time reference). + +For more information on NuGet packages and the runtime store, see the following topics: + +* [How to Create a NuGet Package with Cross Platform Tools](/dotnet/core/deploying/creating-nuget-packages) +* [Publishing packages](/nuget/create-packages/publish-a-package) +* [Runtime package store](/dotnet/core/deploying/runtime-store) + +### Project bin folder + +A hosting startup enhancement can be provided by a *bin*-deployed assembly in the enhanced app. The hosting startup types provided by the assembly are made available to the app using either of the following approaches: + +* The enhanced app's project file makes an assembly reference to the hosting startup (a compile-time reference). With the compile-time reference in place, the hosting startup assembly and all of its dependencies are incorporated into the app's dependency file (*\*.deps.json*). This approach applies when the deployment scenario calls for moving the compiled hosting startup library's assembly (DLL file) to the consuming project or to a location accessible by the consuming project and a compile-time reference is made to the hosting startup's assembly. +* The hosting startup's dependencies file is made available to the enhanced app as described in the [Runtime store](#runtime-store) section (without a compile-time reference). + +## Sample code + +The [sample code](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/host/platform-specific-configuration/samples/) ([how to download](xref:tutorials/index#how-to-download-a-sample)) demonstrates hosting startup implementation scenarios: + +* Two hosting startup assemblies (class libraries) set a pair of in-memory configuration key-value pairs each: + * NuGet package (*HostingStartupPackage*) + * Class library (*HostingStartupLibrary*) +* A hosting startup is activated from a runtime store-deployed assembly (*StartupDiagnostics*). The assembly adds two middlewares to the app at startup that provide diagnostic information on: + * Registered services + * Address (scheme, host, path base, path, query string) + * Connection (remote IP, remote port, local IP, local port, client certificate) + * Request headers + * Environment variables + +To run the sample: + +**Activation from a NuGet package** + +1. Compile the *HostingStartupPackage* package with the [dotnet pack](/dotnet/core/tools/dotnet-pack) command. +1. Add the package's assembly name of the *HostingStartupPackage* to the `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES` environment variable. +1. Compile and run the app. A package reference is present in the enhanced app (a compile-time reference). A `` in the app's project file specifies the package project's output (*../HostingStartupPackage/bin/Debug*) as a package source. This allows the app to use the package without uploading the package to [nuget.org](https://www.nuget.org/). For more information, see the notes in the HostingStartupApp's project file. + + ```xml + + $(RestoreSources);https://api.nuget.org/v3/index.json;../HostingStartupPackage/bin/Debug + + ``` +1. Observe that the service configuration key values rendered by the Index page match the values set by the package's `ServiceKeyInjection.Configure` method. + +If you make changes to the *HostingStartupPackage* project and recompile it, clear the local NuGet package caches to ensure that the *HostingStartupApp* receives the updated package and not a stale package from the local cache. To clear the local NuGet caches, execute the following [dotnet nuget locals](/dotnet/core/tools/dotnet-nuget-locals) command: + +```console +dotnet nuget locals all --clear +``` + +**Activation from a class library** + +1. Compile the *HostingStartupLibrary* class library with the [dotnet build](/dotnet/core/tools/dotnet-build) command. +1. Add the class library's assembly name of *HostingStartupLibrary* to the `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES` environment variable. +1. *bin*-deploy the class library's assembly to the app by copying the *HostingStartupLibrary.dll* file from the class library's compiled output to the app's *bin/Debug* folder. +1. Compile and run the app. An `` in the app's project file references the class library's assembly (*.\bin\Debug\netcoreapp2.1\HostingStartupLibrary.dll*) (a compile-time reference). For more information, see the notes in the HostingStartupApp's project file. + + ```xml + + + .\bin\Debug\netcoreapp2.1\HostingStartupLibrary.dll + False + + + ``` +1. Observe that the service configuration key values rendered by the Index page match the values set by the class library's `ServiceKeyInjection.Configure` method. + +**Activation from a runtime store-deployed assembly** + +1. The *StartupDiagnostics* project uses [PowerShell](/powershell/scripting/powershell-scripting) to modify its *StartupDiagnostics.deps.json* file. PowerShell is installed by default on Windows starting with Windows 7 SP1 and Windows Server 2008 R2 SP1. To obtain PowerShell on other platforms, see [Installing Windows PowerShell](/powershell/scripting/setup/installing-powershell#powershell-core). +1. Build the *StartupDiagnostics* project. After the project is built, a build target in the project file automatically: + * Triggers the PowerShell script to modify the *StartupDiagnostics.deps.json* file. + * Moves the *StartupDiagnostics.deps.json* file to the user profile's *additionalDeps* folder. +1. Execute the `dotnet store` command at a command prompt in the hosting startup's directory to store the assembly and its dependencies in the user profile's runtime store: + + ```console + dotnet store --manifest StartupDiagnostics.csproj --runtime + ``` + For Windows, the command uses the `win7-x64` [runtime identifier (RID)](/dotnet/core/rid-catalog). When providing the hosting startup for a different runtime, substitute the correct RID. +1. Set the environment variables: + * Add the assembly name of *StartupDiagnostics* to the `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES` environment variable. + * On Windows, set the `DOTNET_ADDITIONAL_DEPS` environment variable to `%UserProfile%\.dotnet\x64\additionalDeps\StartupDiagnostics\`. On macOS/Linux, set the `DOTNET_ADDITIONAL_DEPS` environment variable to `/Users//.dotnet/x64/additionalDeps/StartupDiagnostics/`, where `` is the user profile that contains the hosting startup. +1. Run the sample app. +1. Request the `/services` endpoint to see the app's registered services. Request the `/diag` endpoint to see the diagnostic information. diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.cs similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement.cs rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.cs diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement.csproj b/aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.csproj similarity index 85% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement.csproj rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.csproj index 184d2c8e83e2..b436fc3d36fe 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement.csproj +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement.csproj @@ -6,7 +6,7 @@ + Version="2.1.1" /> diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement1.deps.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement1.deps.json similarity index 77% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement1.deps.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement1.deps.json index 3ce8cf105917..0ae18cbf003d 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement1.deps.json +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement1.deps.json @@ -3,7 +3,7 @@ ".NETCoreApp,Version=v2.1": { "StartupEnhancement/1.0.0": { "dependencies": { - "Microsoft.AspNetCore.Hosting.Abstractions": "2.1.0" + "Microsoft.AspNetCore.Hosting.Abstractions": "2.1.1" }, "runtime": { "StartupEnhancement.dll": {} diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement2.deps.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement2.deps.json similarity index 78% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement2.deps.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement2.deps.json index 2ea2030572ea..c3916e6aef8f 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/snapshot_sample/StartupEnhancement2.deps.json +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples-snapshot/2.x/StartupEnhancement2.deps.json @@ -3,7 +3,7 @@ ".NETCoreApp,Version=v2.1": { "StartupEnhancement/1.0.0": { "dependencies": { - "Microsoft.AspNetCore.Hosting.Abstractions": "2.1.0" + "Microsoft.AspNetCore.Hosting.Abstractions": "2.1.1" }, "runtime": { "lib/netcoreapp2.1/StartupEnhancement.dll": {} diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/HostingStartupApp.csproj b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/HostingStartupApp.csproj new file mode 100644 index 000000000000..344f8b359cbe --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/HostingStartupApp.csproj @@ -0,0 +1,60 @@ + + + + netcoreapp2.1 + + + + + + + + + + $(RestoreSources);https://api.nuget.org/v3/index.json;../HostingStartupPackage/bin/Debug + + + + + + .\bin\Debug\netcoreapp2.1\HostingStartupLibrary.dll + False + + + + diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Error.cshtml b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Error.cshtml similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Error.cshtml rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Error.cshtml diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Error.cshtml.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Error.cshtml.cs similarity index 93% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Error.cshtml.cs rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Error.cshtml.cs index f5922e7610c4..5e88b2282e73 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Error.cshtml.cs +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Error.cshtml.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace HostingStartupSample.Pages +namespace HostingStartupApp.Pages { public class ErrorModel : PageModel { diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml new file mode 100644 index 000000000000..9ed44869465c --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml @@ -0,0 +1,87 @@ +@page +@model IndexModel +@{ + ViewData["Title"] = "Hosting Startup Sample"; +} + +

@ViewData["Title"]

+ +
+
+
+
+

Consume hosting startup from a bin-deployed library

+
+
+

Add configuration

+

+ When an IHostingStartup enhancement is available from an existing library, the types provided by the library can be made available by bin-deploying the library's assembly and adding the hosting startup assembly name to the ASPNETCORE_HOSTINGSTARTUPASSEMBLIES environment variable. +

+

+ The hosting startup of the class library adds an in-memory configuration provider to the app that specifies values for the service keys shown below. +

+

Service Keys

+
    +
  • Development Service Key from Library: @Model.ServiceKey_Development_Library
  • +
  • Production Service Key from Library: @Model.ServiceKey_Production_Library
  • +
+
+
+
+
+ +
+
+
+
+

Consume hosting startup from a NuGet package

+
+
+

Add configuration

+

+ When an IHostingStartup enhancement is available from an existing NuGet package, the types provided by the package can be made available by referencing the package and adding the hosting startup assembly name to the ASPNETCORE_HOSTINGSTARTUPASSEMBLIES environment variable. +

+

+ The hosting startup of the NuGet package adds an in-memory configuration provider to the app that specifies values for the service keys shown below. +

+

Service Keys

+
    +
  • Development Service Key from Package: @Model.ServiceKey_Development_Package
  • +
  • Production Service Key from Package: @Model.ServiceKey_Production_Package
  • +
+
+
+
+
+ +
+
+
+
+

Startup Diagnostics Instructions

+
+
+

Obtain a list of services

+

+ When the IHostingStartup implementation's Configure method executes, a factory is registered that implements a method to obtain the app's service collection descriptors. An implementation of IStartupFilter branches the request pipeline for the path /services, which executes a terminal middleware delegate. The delegate produces a webpage showing the app's services using the factory's GetServices method. +

+

+ To see the services in the service collection of the app, request the /services endpoint from the running app. +

+

Obtain diagnostic information

+

+ The implementation of IStartupFilter also registers a middleware, DiagnosticMiddleware, that outputs diagonistic information on the: +

    +
  • Request
  • +
  • Connection
  • +
  • Headers
  • +
  • Environment variables
  • +
+

+

+ To see the diagnostic information from the app, request the /diag endpoint from the running app. +

+
+
+
+
diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml.cs new file mode 100644 index 000000000000..c8084b746dfb --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Index.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Configuration; + +namespace HostingStartupApp.Pages +{ + #region snippet1 + public class IndexModel : PageModel + { + public IndexModel(IConfiguration config) + { + ServiceKey_Development_Library = config["DevAccount_FromLibrary"]; + ServiceKey_Production_Library = config["ProdAccount_FromLibrary"]; + ServiceKey_Development_Package = config["DevAccount_FromPackage"]; + ServiceKey_Production_Package = config["ProdAccount_FromPackage"]; + } + + public string ServiceKey_Development_Library { get; private set; } + public string ServiceKey_Production_Library { get; private set; } + public string ServiceKey_Development_Package { get; private set; } + public string ServiceKey_Production_Package { get; private set; } + + public void OnGet() + { + } + } + #endregion +} diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Shared/_CookieConsentPartial.cshtml b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Shared/_CookieConsentPartial.cshtml similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Shared/_CookieConsentPartial.cshtml rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Shared/_CookieConsentPartial.cshtml diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Shared/_Layout.cshtml b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Shared/_Layout.cshtml similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Shared/_Layout.cshtml rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Shared/_Layout.cshtml diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Shared/_ValidationScriptsPartial.cshtml b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Shared/_ValidationScriptsPartial.cshtml similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/Shared/_ValidationScriptsPartial.cshtml rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/Shared/_ValidationScriptsPartial.cshtml diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/_ViewImports.cshtml b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/_ViewImports.cshtml new file mode 100644 index 000000000000..46719b719933 --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@using HostingStartupApp +@namespace HostingStartupApp.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/_ViewStart.cshtml b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/_ViewStart.cshtml similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Pages/_ViewStart.cshtml rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Pages/_ViewStart.cshtml diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Program.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Program.cs similarity index 94% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Program.cs rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Program.cs index c314aaef0ca4..d9c60bbc201a 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Program.cs +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Program.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -namespace HostingStartupSample +namespace HostingStartupApp { public class Program { @@ -21,7 +21,7 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) => // To scan the assembly for HostingStartupAttributes, the // ApplicationName must be set. This can be done with // UseSetting, Configure, or UseStartup. - // .UseSetting(WebHostDefaults.ApplicationKey, "HostingStartupSample") + // .UseSetting(WebHostDefaults.ApplicationKey, "HostingStartupApp") // .Configure(_ => { }) .UseStartup(); } diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/README.md b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/README.md similarity index 79% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/README.md rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/README.md index 1c0de4e94ccd..c96bc2ce2938 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/README.md +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/README.md @@ -1,3 +1,3 @@ # ASP.NET Core Hosting Startup Sample -This sample illustrates the use of [IHostingStartup](https://docs.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup). This sample demonstrates the scenarios described in [Enhance an app from an external assembly](https://docs.microsoft.com/aspnet/core/fundamentals/configuration/platform-specific-configuration). +This sample illustrates the use of [IHostingStartup](https://docs.microsoft.com/dotnet/api/microsoft.aspnetcore.hosting.ihostingstartup). This sample demonstrates the scenarios described in [Enhance an app from an external assembly](https://docs.microsoft.com/aspnet/core/fundamentals/host/platform-specific-configuration). diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Startup.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Startup.cs similarity index 97% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Startup.cs rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Startup.cs index 12c576fdf43a..cb19f7d856e8 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/Startup.cs +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/Startup.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; -namespace HostingStartupSample +namespace HostingStartupApp { public class Startup { diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/appsettings.Development.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/appsettings.Development.json similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/appsettings.Development.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/appsettings.Development.json diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/appsettings.Production.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/appsettings.Production.json similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/appsettings.Production.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/appsettings.Production.json diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/appsettings.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/appsettings.json similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/appsettings.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/appsettings.json diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/css/site.css b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/css/site.css similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/css/site.css rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/css/site.css diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/css/site.min.css b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/css/site.min.css similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/css/site.min.css rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/css/site.min.css diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/favicon.ico b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/favicon.ico similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/favicon.ico rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/favicon.ico diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/js/site.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/js/site.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/js/site.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/js/site.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/js/site.min.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/js/site.min.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/js/site.min.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/js/site.min.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/.bower.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/.bower.json similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/.bower.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/.bower.json diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/LICENSE b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/LICENSE similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/LICENSE rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/LICENSE diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css.map b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css.map similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css.map rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css.map diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css.map b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css.map similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css.map rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.min.css.map diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.css b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.css similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.css rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.css diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.svg b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.svg rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.svg diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/js/bootstrap.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/js/bootstrap.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/js/bootstrap.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/js/bootstrap.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/js/npm.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/js/npm.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/bootstrap/dist/js/npm.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/bootstrap/dist/js/npm.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/.bower.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/.bower.json similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/.bower.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/.bower.json diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/.bower.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/.bower.json similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/.bower.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/.bower.json diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/LICENSE.md b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/LICENSE.md similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/LICENSE.md rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/LICENSE.md diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/additional-methods.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/additional-methods.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/additional-methods.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/additional-methods.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/additional-methods.min.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/additional-methods.min.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/additional-methods.min.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/additional-methods.min.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/jquery.validate.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/jquery.validate.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/jquery.validate.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/jquery.validate.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/.bower.json b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/.bower.json similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/.bower.json rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/.bower.json diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/LICENSE.txt b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/LICENSE.txt similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/LICENSE.txt rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/LICENSE.txt diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/dist/jquery.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/dist/jquery.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/dist/jquery.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/dist/jquery.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/dist/jquery.min.js b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/dist/jquery.min.js similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/dist/jquery.min.js rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/dist/jquery.min.js diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/dist/jquery.min.map b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/dist/jquery.min.map similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/HostingStartupSample/wwwroot/lib/jquery/dist/jquery.min.map rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupApp/wwwroot/lib/jquery/dist/jquery.min.map diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupLibrary/HostingStartupLibrary.csproj b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupLibrary/HostingStartupLibrary.csproj new file mode 100644 index 000000000000..f8dae5aa158f --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupLibrary/HostingStartupLibrary.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + + + + + + + + diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupLibrary/ServiceKeyInjection.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupLibrary/ServiceKeyInjection.cs new file mode 100644 index 000000000000..b3c889f8c87c --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupLibrary/ServiceKeyInjection.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +#region snippet1 +[assembly: HostingStartup(typeof(HostingStartupLibrary.ServiceKeyInjection))] + +namespace HostingStartupLibrary +{ + public class ServiceKeyInjection : IHostingStartup + { + public void Configure(IWebHostBuilder builder) + { + builder.ConfigureAppConfiguration(config => + { + var dict = new Dictionary + { + {"DevAccount_FromLibrary", "DEV_1111111-1111"}, + {"ProdAccount_FromLibrary", "PROD_2222222-2222"} + }; + + config.AddInMemoryCollection(dict); + }); + } + } +} +#endregion diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupPackage/HostingStartupPackage.csproj b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupPackage/HostingStartupPackage.csproj new file mode 100644 index 000000000000..b4ddfee468ae --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupPackage/HostingStartupPackage.csproj @@ -0,0 +1,14 @@ + + + + netstandard2.0 + HostingStartupPackage + 1.0.0 + + + + + + + + diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupPackage/ServiceKeyInjection.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupPackage/ServiceKeyInjection.cs new file mode 100644 index 000000000000..e8e3db34ccf8 --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/HostingStartupPackage/ServiceKeyInjection.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +#region snippet1 +[assembly: HostingStartup(typeof(HostingStartupPackage.ServiceKeyInjection))] + +namespace HostingStartupPackage +{ + public class ServiceKeyInjection : IHostingStartup + { + public void Configure(IWebHostBuilder builder) + { + builder.ConfigureAppConfiguration(config => + { + var dict = new Dictionary + { + {"DevAccount_FromPackage", "DEV_3333333-3333"}, + {"ProdAccount_FromPackage", "PROD_4444444-4444"} + }; + + config.AddInMemoryCollection(dict); + }); + } + } +} +#endregion diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/ServiceDescriptorsFactory.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/ServiceDescriptorsFactory.cs similarity index 61% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/ServiceDescriptorsFactory.cs rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/ServiceDescriptorsFactory.cs index ea7ccbe5db4a..84c4708d5e5a 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/ServiceDescriptorsFactory.cs +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/ServiceDescriptorsFactory.cs @@ -5,27 +5,56 @@ // by middleware to provide a list of the app's registered services. namespace ServiceDescriptorsFactory { + /// + /// Describes an individual service in the app. + /// public class AppService { + /// + /// Full name of the service. + /// public string FullName { get; set; } + + /// + /// Lifetime of the service registration. + /// public string Lifetime { get; set; } + + /// + /// Implementation type of the service. + /// public string ImplementationType { get; set; } } + /// + /// Service descriptor interface. + /// public interface IServiceDescriptorsService { + /// + /// GetServices method returns an IEnumerable of app services. + /// IEnumerable GetServices(); } + /// + /// A service to describe the app's services. + /// public class ServiceDescriptorsService : IServiceDescriptorsService { private readonly IServiceCollection _serviceCollection; - + + /// + /// Construct the ServiceDescriptorsService. + /// public ServiceDescriptorsService(IServiceCollection serviceCollection) { _serviceCollection = serviceCollection; } + /// + /// Return an IEnumerable of app services. + /// public IEnumerable GetServices() { foreach (var srv in _serviceCollection) diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/StartupDiagnostics.cs b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/StartupDiagnostics.cs similarity index 88% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/StartupDiagnostics.cs rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/StartupDiagnostics.cs index 9dd4a005c8a5..ce97a061a52f 100644 --- a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/StartupDiagnostics.cs +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/StartupDiagnostics.cs @@ -14,8 +14,14 @@ namespace StartupDiagnostics { + /// + /// Class used to configure the app with the hosting startup enhancements. + /// public class StartupDiagnosticsHostingStartup : IHostingStartup { + /// + /// Configure the IWebHostBuilder with the hosting startup enhancements. + /// public void Configure(IWebHostBuilder builder) { Console.WriteLine("StartupDiagnostics.StartupDiagnosticsHostingStartup"); @@ -38,15 +44,24 @@ public void Configure(IWebHostBuilder builder) } } + /// + /// Startup filter for diagnostic middleware. + /// public class DiagnosticMiddlewareStartupFilter : IStartupFilter { private readonly IHostingEnvironment _env; + /// + /// Construct diagnostic middleware startup filter. + /// public DiagnosticMiddlewareStartupFilter(IHostingEnvironment env) { _env = env; } + /// + /// Configure diagnostic middleware. + /// public Action Configure(Action next) { return app => @@ -99,7 +114,9 @@ public Action Configure(Action next) } } - // Use a middleware to write out diagnostic information from the app. + /// + /// A middleware to write out diagnostic information from the app. + /// public class DiagnosticMiddleware { private readonly RequestDelegate _next; @@ -107,6 +124,9 @@ public class DiagnosticMiddleware private readonly IHostingEnvironment _env; private string cr = Environment.NewLine; + /// + /// Construct the diagnostic middleware. + /// public DiagnosticMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, IHostingEnvironment env) @@ -116,6 +136,9 @@ public DiagnosticMiddleware(RequestDelegate next, _env = env; } + /// + /// Invoke the diagnostic middleware. + /// public async Task Invoke(HttpContext ctx) { var path = ctx.Request.Path; diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/StartupDiagnostics.csproj b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/StartupDiagnostics.csproj new file mode 100644 index 000000000000..a3ef1f1cf1d0 --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/StartupDiagnostics.csproj @@ -0,0 +1,50 @@ + + + + netcoreapp2.1 + 2.1.0 + 1.0.0 + true + aspnetcore;StartupDiagnostics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/deploy.ps1 b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/deploy.ps1 new file mode 100644 index 000000000000..ac589a1202d8 --- /dev/null +++ b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/deploy.ps1 @@ -0,0 +1,24 @@ +function SetEnvironmentVariables +{ + # Set StartupDiagnostics into the ASPNETCORE_HOSTINGSTARTUPASSEMBLIES environment variable + $value = [Environment]::GetEnvironmentVariable('ASPNETCORE_HOSTINGSTARTUPASSEMBLIES', 'Machine') + if ($value -eq $null) { + [Environment]::SetEnvironmentVariable('ASPNETCORE_HOSTINGSTARTUPASSEMBLIES', 'StartupDiagnostics', 'Machine') + } else { + if ($value -notlike '*StartupDiagnostics*') { + [Environment]::SetEnvironmentVariable('ASPNETCORE_HOSTINGSTARTUPASSEMBLIES', $value + ';StartupDiagnostics', 'Machine') + } + } + + # Set the hosting startup dependencies path into DOTNET_ADDITIONAL_DEPS + $value = [Environment]::GetEnvironmentVariable('DOTNET_ADDITIONAL_DEPS', 'Machine') + if ($value -eq $null) { + [Environment]::SetEnvironmentVariable('DOTNET_ADDITIONAL_DEPS', '%UserProfile%\.dotnet\x64\additionalDeps\StartupDiagnostics\', 'Machine') + } else { + if ($value -notlike '*StartupDiagnostics*') { + [Environment]::SetEnvironmentVariable('DOTNET_ADDITIONAL_DEPS', $value + ';%UserProfile%\.dotnet\x64\additionalDeps\StartupDiagnostics\', 'Machine') + } + } +} + +SetEnvironmentVariables diff --git a/aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/modify_deps_json.ps1 b/aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/modify_deps_json.ps1 similarity index 100% rename from aspnetcore/fundamentals/configuration/platform-specific-configuration/sample/StartupDiagnostics/modify_deps_json.ps1 rename to aspnetcore/fundamentals/host/platform-specific-configuration/samples/2.x/StartupDiagnostics/modify_deps_json.ps1 diff --git a/aspnetcore/fundamentals/host/web-host.md b/aspnetcore/fundamentals/host/web-host.md index 82ccf50f20bb..ea43c2a1ed4e 100644 --- a/aspnetcore/fundamentals/host/web-host.md +++ b/aspnetcore/fundamentals/host/web-host.md @@ -335,6 +335,23 @@ WebHost.CreateDefaultBuilder(args) .UseSetting("https_port", "8080") ``` +### Hosting Startup Exclude Assemblies + +DESCRIPTION + +**Key**: hostingStartupExcludeAssemblies +**Type**: *string* +**Default**: Empty string +**Set using**: `UseSetting` +**Environment variable**: `ASPNETCORE_HOSTINGSTARTUPEXCLUDEASSEMBLIES` + +A semicolon-delimited string of hosting startup assemblies to exclude on startup. + +```csharp +WebHost.CreateDefaultBuilder(args) + .UseSetting(WebHostDefaults.HostingStartupExcludeAssembliesKey, "assembly1;assembly2") +``` + ::: moniker-end ::: moniker range=">= aspnetcore-2.0" diff --git a/aspnetcore/toc.md b/aspnetcore/toc.md index d7af1d45d78e..304c5506bcdd 100644 --- a/aspnetcore/toc.md +++ b/aspnetcore/toc.md @@ -127,7 +127,6 @@ ## [Configuration and options](xref:fundamentals/configuration/index) ### [Configuration](xref:fundamentals/configuration/index) ### [Options](xref:fundamentals/configuration/options) -### [Enhance an app from an external assembly](xref:fundamentals/configuration/platform-specific-configuration) ## [Logging](xref:fundamentals/logging/index) ### [Logging with LoggerMessage](xref:fundamentals/logging/loggermessage) ## [Handle errors](fundamentals/error-handling.md) @@ -135,6 +134,7 @@ ### [Web Host](xref:fundamentals/host/web-host) ### [Generic Host](xref:fundamentals/host/generic-host) ### [Background tasks with hosted services](xref:fundamentals/host/hosted-services) +### [Enhance an app from an external assembly](xref:fundamentals/configuration/platform-specific-configuration) ## [Servers](xref:fundamentals/servers/index) ### [Kestrel](xref:fundamentals/servers/kestrel) ### [ASP.NET Core Module](xref:fundamentals/servers/aspnet-core-module)