diff --git a/src/Microsoft.AspNetCore.Blazor.Server/BlazorAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Blazor.Server/BlazorAppBuilderExtensions.cs index e3097bd052..366ebca7cc 100644 --- a/src/Microsoft.AspNetCore.Blazor.Server/BlazorAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Blazor.Server/BlazorAppBuilderExtensions.cs @@ -7,27 +7,40 @@ using Microsoft.Extensions.FileProviders; using System.Collections.Generic; using System.IO; using System.Net.Mime; +using System; namespace Microsoft.AspNetCore.Builder { public static class BlazorAppBuilderExtensions { + /// + /// Configures the middleware pipeline to work with Blazor. + /// + /// + /// The name of the client assembly relative to the current bin directory. public static void UseBlazor( this IApplicationBuilder applicationBuilder, string clientAssemblyName) { var binDir = Path.GetDirectoryName(typeof(BlazorConfig).Assembly.Location); var clientAssemblyPath = Path.Combine(binDir, $"{clientAssemblyName}.dll"); - applicationBuilder.UseBlazorInternal(clientAssemblyPath); + applicationBuilder.UseBlazor(new BlazorOptions + { + ClientAssemblyPath = clientAssemblyPath, + }); } - - // TODO: Change this combination of APIs to make it possible to supply either - // an assembly name (resolved to current bin dir) or full assembly path - internal static void UseBlazorInternal( + + /// + /// Configures the middleware pipeline to work with Blazor. + /// + /// + /// + public static void UseBlazor( this IApplicationBuilder applicationBuilder, - string clientAssemblyPath) + BlazorOptions options) { - var config = BlazorConfig.Read(clientAssemblyPath); + var config = BlazorConfig.Read(options.ClientAssemblyPath); var clientAppBinDir = Path.GetDirectoryName(config.SourceOutputAssemblyPath); var clientAppDistDir = Path.Combine(clientAppBinDir, "dist"); var distFileProvider = new PhysicalFileProvider(clientAppDistDir); diff --git a/src/Microsoft.AspNetCore.Blazor.Server/BlazorOptions.cs b/src/Microsoft.AspNetCore.Blazor.Server/BlazorOptions.cs new file mode 100644 index 0000000000..d6556dbc27 --- /dev/null +++ b/src/Microsoft.AspNetCore.Blazor.Server/BlazorOptions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.AspNetCore.Blazor.Server +{ + public class BlazorOptions + { + /// + /// Full path to the client assembly. + /// + public string ClientAssemblyPath { get; set; } + } +}