Skip to content

Commit

Permalink
Merge pull request #20630 from abpframework/auto-merge/rel-8-3/2938
Browse files Browse the repository at this point in the history
Merge branch dev with rel-8.3
  • Loading branch information
maliming authored Aug 26, 2024
2 parents 713294f + 389da84 commit 5018796
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Volo.Abp.AspNetCore.Mvc.Libs;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.Data;
using Volo.Abp.Minify;
using Volo.Abp.Modularity;

Expand All @@ -14,9 +15,12 @@ public class AbpAspNetCoreMvcUiBundlingModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpMvcLibsOptions>(options =>
if (!context.Services.IsDataMigrationEnvironment())
{
options.CheckLibs = true;
});
Configure<AbpMvcLibsOptions>(options =>
{
options.CheckLibs = true;
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand All @@ -25,7 +23,14 @@ public virtual void CheckLibs(ApplicationInitializationContext context)
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpMvcLibsOptions>>().Value;
if (options.CheckLibs)
{
var app = context.GetApplicationBuilder();
var app = context.GetApplicationBuilderOrNull();
if (app == null)
{
var logger = context.ServiceProvider.GetRequiredService<ILogger<AbpMvcLibsService>>();
logger.LogWarning($"The {nameof(IApplicationBuilder)} is not available. The 'CheckLibs' feature is disabled!");
return;
}

app.Use(async (httpContext, next) =>
{
if (!await CheckLibsAsyncOnceAsync(httpContext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ public static class ApplicationInitializationContextExtensions
{
public static IApplicationBuilder GetApplicationBuilder(this ApplicationInitializationContext context)
{
return context.ServiceProvider.GetRequiredService<IObjectAccessor<IApplicationBuilder>>().Value!;
var applicationBuilder = context.ServiceProvider.GetRequiredService<IObjectAccessor<IApplicationBuilder>>().Value;
Check.NotNull(applicationBuilder, nameof(applicationBuilder));
return applicationBuilder;
}

public static IApplicationBuilder? GetApplicationBuilderOrNull(this ApplicationInitializationContext context)
{
return context.ServiceProvider.GetRequiredService<IObjectAccessor<IApplicationBuilder>>().Value;
}

public static IWebHostEnvironment GetEnvironment(this ApplicationInitializationContext context)
Expand Down

0 comments on commit 5018796

Please sign in to comment.