修复 ASP.NET Core 已弃用的包

问题描述 投票:0回答:1

由于encodings.web 的旧版本,我收到了 Mend Bolt 警告:

system.text.encodings.web.4.5.0.nupkg
。 4.5.0版本存在安全漏洞。我需要升级到更高版本。

它是从

Microsoft.AspNetCore.Hosting.Abstractions
:

添加为传递包的

问题是

Microsoft.AspNetCore.Hosting.Abstractions
的 2.2.0 版本已被弃用。

我的项目使用 .NET 6。我找不到更新格式或其他变体的包。我将

Hosting.Abstractions
用于
IWebHost
类,作为迁移扩展方法。如果我卸载它,那么警告就会解决,但我的方法不会构建。

public static IWebHost MigrateDbContext<TContext>(this IWebHost webHost, Action<TContext, IServiceProvider> seeder) where TContext : DbContext
{
    var services = scope.ServiceProvider;
    var logger = services.GetRequiredService<ILogger<TContext>>();
    var context = services.GetService<TContext>();
    ...
    context.Database.Migrate();
    ...
}
asp.net-core nuget upgrade nuget-package deprecated
1个回答
0
投票

我为该易受攻击的软件包安装了最新的稳定版本。将来,在我升级到另一个 .NET 版本后,也许该漏洞消失了,我将需要返回并从

.csproj
中删除该行,其中 Drawing.Common 设置为今天的最新版本。

<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
© www.soinside.com 2019 - 2024. All rights reserved.