From 04165fd54390d56796a5374cd3d77c5e004f9902 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 1 Jan 2025 13:29:41 +0800 Subject: [PATCH 1/4] Use `StaticFiles` instead of `MapStaticAssets` in `Development`. --- .../Builder/AbpApplicationBuilderExtensions.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index 1bf3e45e4a..2dbd73a3ee 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -177,6 +177,15 @@ public static class AbpApplicationBuilderExtensions throw new AbpException("The app(IApplicationBuilder) is not an IEndpointRouteBuilder."); } + var environment = endpoints.ServiceProvider.GetRequiredService(); + if (environment.IsDevelopment()) + { + app.UseStaticFiles(); + // Volo.Abp.AspNetCore.staticwebassets.endpoints.json is a empty file. + // https://github.com/dotnet/aspnetcore/issues/59673 + return endpoints.MapStaticAssets("Volo.Abp.AspNetCore.staticwebassets.endpoints.json"); + } + var options = app.ApplicationServices.GetRequiredService>().Value; foreach (var folder in options.AllowedExtraWebContentFolders) { From 901021e40f01a4aaa00af2c7293ab37299e44880 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 1 Jan 2025 13:47:21 +0800 Subject: [PATCH 2/4] Create `staticwebassets.endpoints.json` if it doesn't exist. --- .../AspNetCore/Builder/AbpApplicationBuilderExtensions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index 2dbd73a3ee..cfd7eb515b 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -183,7 +183,12 @@ public static class AbpApplicationBuilderExtensions app.UseStaticFiles(); // Volo.Abp.AspNetCore.staticwebassets.endpoints.json is a empty file. // https://github.com/dotnet/aspnetcore/issues/59673 - return endpoints.MapStaticAssets("Volo.Abp.AspNetCore.staticwebassets.endpoints.json"); + var tempStaticAssetsManifestPath = Path.Combine(AppContext.BaseDirectory, "Volo.Abp.AspNetCore.staticwebassets.endpoints.json"); + if (!File.Exists(tempStaticAssetsManifestPath)) + { + File.WriteAllText(tempStaticAssetsManifestPath, "{\"Version\":1,\"ManifestType\":\"Build\",\"Endpoints\":[]}"); + } + return endpoints.MapStaticAssets(tempStaticAssetsManifestPath); } var options = app.ApplicationServices.GetRequiredService>().Value; From eca1cd493677166025665f12b6be052ea12802a9 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 1 Jan 2025 13:49:14 +0800 Subject: [PATCH 3/4] Update AbpApplicationBuilderExtensions.cs --- .../AspNetCore/Builder/AbpApplicationBuilderExtensions.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index cfd7eb515b..57be65b0da 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -180,9 +180,11 @@ public static class AbpApplicationBuilderExtensions var environment = endpoints.ServiceProvider.GetRequiredService(); if (environment.IsDevelopment()) { - app.UseStaticFiles(); - // Volo.Abp.AspNetCore.staticwebassets.endpoints.json is a empty file. + // MapStaticAssets in development mode will have a performance issue if there are many static files. // https://github.com/dotnet/aspnetcore/issues/59673 + app.UseStaticFiles(); + + // Volo.Abp.AspNetCore.staticwebassets.endpoints.json is a 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)) { From 5576ef5d8f430b40cb8345e73dac059f1ce4a8fb Mon Sep 17 00:00:00 2001 From: EngincanV Date: Thu, 2 Jan 2025 10:39:39 +0300 Subject: [PATCH 4/4] Update AbpApplicationBuilderExtensions.cs --- .../AspNetCore/Builder/AbpApplicationBuilderExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index 57be65b0da..f0ca14657b 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -184,7 +184,7 @@ public static class AbpApplicationBuilderExtensions // https://github.com/dotnet/aspnetcore/issues/59673 app.UseStaticFiles(); - // Volo.Abp.AspNetCore.staticwebassets.endpoints.json is a empty file. Just compatible with the return type of MapAbpStaticAssets. + // 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)) {