Fix regression in app startup when running in E2E tests
This commit is contained in:
parent
ff5b6a7f30
commit
de2bfe5162
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Blazor.Server\Microsoft.AspNetCore.Blazor.Server.csproj" />
|
||||
<ProjectReference Include="..\HostedInAspNet.Client\HostedInAspNet.Client.csproj" ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="..\HostedInAspNet.Client\HostedInAspNet.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace HostedInAspNet.Server
|
|||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseBlazor("HostedInAspNet.Client");
|
||||
app.UseBlazor<Client.Program>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Blazor.Server\Microsoft.AspNetCore.Blazor.Server.csproj" />
|
||||
<ProjectReference Include="..\MonoSanityClient\MonoSanityClient.csproj" ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="..\MonoSanityClient\MonoSanityClient.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace MonoSanity
|
|||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseFileServer(new FileServerOptions { EnableDefaultFiles = true });
|
||||
app.UseBlazor("MonoSanityClient");
|
||||
app.UseBlazor<MonoSanityClient.Program>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
// 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.
|
||||
|
||||
namespace MonoSanityClient
|
||||
{
|
||||
// Note: Not used at runtime. This exists only to give the server app some type to reference.
|
||||
// In realistic scenarios you'd have a Program class for real.
|
||||
|
||||
public class Program
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -16,18 +16,15 @@ namespace Microsoft.AspNetCore.Builder
|
|||
/// <summary>
|
||||
/// Configures the middleware pipeline to work with Blazor.
|
||||
/// </summary>
|
||||
/// <typeparam name="TProgram">Any type from the client app project. This is used to identify the client app assembly.</typeparam>
|
||||
/// <param name="applicationBuilder"></param>
|
||||
/// <param name="clientAssemblyName"
|
||||
/// >The name of the client assembly relative to the current bin directory.</param>
|
||||
public static void UseBlazor(
|
||||
this IApplicationBuilder applicationBuilder,
|
||||
string clientAssemblyName)
|
||||
public static void UseBlazor<TProgram>(
|
||||
this IApplicationBuilder applicationBuilder)
|
||||
{
|
||||
var binDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
var clientAssemblyPath = Path.Combine(binDir, $"{clientAssemblyName}.dll");
|
||||
var clientAssemblyInServerBinDir = typeof(TProgram).Assembly;
|
||||
applicationBuilder.UseBlazor(new BlazorOptions
|
||||
{
|
||||
ClientAssemblyPath = clientAssemblyPath,
|
||||
ClientAssemblyPath = clientAssemblyInServerBinDir.Location,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue