Moved the static assets extension method to WebHostBuilderExtensions. (#11541)

* Moved the static assets extension method to WebHostBuilderExtensions.

* Updated the refs
This commit is contained in:
David Fowler 2019-06-25 06:28:40 -07:00 committed by GitHub
parent 6608b3b178
commit 73e1b5de9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 34 deletions

View File

@ -22,10 +22,6 @@ namespace Microsoft.AspNetCore.Hosting
public virtual void ConfigureContainer(TBuilder builder) { }
public override System.IServiceProvider CreateServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
}
public static partial class StaticWebAssetsWebHostBuilderExtensions
{
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStaticWebAssets(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { throw null; }
}
public partial class WebHostBuilder : Microsoft.AspNetCore.Hosting.IWebHostBuilder
{
public WebHostBuilder() { }
@ -47,6 +43,7 @@ namespace Microsoft.AspNetCore.Hosting
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseDefaultServiceProvider(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder, System.Action<Microsoft.Extensions.DependencyInjection.ServiceProviderOptions> configure) { throw null; }
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder, System.Type startupType) { throw null; }
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup<TStartup>(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder) where TStartup : class { throw null; }
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStaticWebAssets(this Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { throw null; }
}
public static partial class WebHostExtensions
{

View File

@ -1,30 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.StaticWebAssets;
namespace Microsoft.AspNetCore.Hosting
{
/// <summary>
/// Extensions for configuring static web assets for development.
/// </summary>
public static class StaticWebAssetsWebHostBuilderExtensions
{
/// <summary>
/// Configures the <see cref="IWebHostEnvironment.WebRootFileProvider"/> to use static web assets
/// defined by referenced projects and packages.
/// </summary>
/// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
public static IWebHostBuilder UseStaticWebAssets(this IWebHostBuilder builder)
{
builder.ConfigureAppConfiguration((context, configBuilder) =>
{
StaticWebAssetsLoader.UseStaticWebAssets(context.HostingEnvironment);
});
return builder;
}
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting.StaticWebAssets;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@ -177,5 +178,21 @@ namespace Microsoft.AspNetCore.Hosting
{
return hostBuilder.ConfigureServices((context, collection) => collection.AddLogging(builder => configureLogging(context, builder)));
}
/// <summary>
/// Configures the <see cref="IWebHostEnvironment.WebRootFileProvider"/> to use static web assets
/// defined by referenced projects and packages.
/// </summary>
/// <param name="builder">The <see cref="IWebHostBuilder"/>.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
public static IWebHostBuilder UseStaticWebAssets(this IWebHostBuilder builder)
{
builder.ConfigureAppConfiguration((context, configBuilder) =>
{
StaticWebAssetsLoader.UseStaticWebAssets(context.HostingEnvironment);
});
return builder;
}
}
}