Browse Source

Map static assets if there is a blazor client project.

pull/22306/head
maliming 1 year ago
parent
commit
912a909a0b
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 17
      framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs

17
framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs

@ -9,8 +9,10 @@ using Microsoft.AspNetCore.StaticAssets;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp;
using Volo.Abp.AspNetCore;
using Volo.Abp.AspNetCore.Auditing;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Security;
@ -184,6 +186,21 @@ public static class AbpApplicationBuilderExtensions
// https://github.com/dotnet/aspnetcore/issues/59673
app.UseStaticFiles();
if (!staticAssetsManifestPath.IsNullOrWhiteSpace())
{
app.ApplicationServices.GetRequiredService<ILogger<AbpAspNetCoreModule>>().LogWarning(
$"The staticAssetsManifestPath({staticAssetsManifestPath}) parameter your provided in MapAbpStaticAssets method is ignored in development mode.");
}
var blazorClientStaticAssetsManifest = Path.Combine(AppContext.BaseDirectory, $"{environment.ApplicationName}.Client.staticwebassets.endpoints.json");
if (File.Exists(blazorClientStaticAssetsManifest))
{
// We have a blazor client project and we need to map the static assets from the client project.
var blazorHostStaticAssetsManifest = Path.Combine(AppContext.BaseDirectory, $"{environment.ApplicationName}.staticwebassets.endpoints.json");
File.Copy(blazorClientStaticAssetsManifest, blazorHostStaticAssetsManifest, true);
return endpoints.MapStaticAssets(blazorHostStaticAssetsManifest);
}
// Volo.Abp.AspNetCore.staticwebassets.endpoints.json is an empty file. Just compatible with the return type of MapAbpStaticAssets.
var tempStaticAssetsManifestPath = Path.Combine(AppContext.BaseDirectory, "Volo.Abp.AspNetCore.staticwebassets.endpoints.json");
if (!File.Exists(tempStaticAssetsManifestPath))

Loading…
Cancel
Save