主要升级步骤如下:

将 .csproj 项目文件中的 target framework 改为 netcoreapp2.1

<TargetFramework>netcoreapp2.1</TargetFramework>

将 Microsoft 开头的 nuget 包升级为 2.1.0-rc1-final  (正式版改为 2.1.0 ),System 开头的 nuget 包升级为 4.5.0-rc1(正式版改为 4.5.0)(这个我没用)

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0-rc1-final" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0-rc1" />

将 Microsoft.AspNetCore.All 更改为 Microsoft.AspNetCore.App

<PackageReference Include="Microsoft.AspNetCore.App" />

在 Program 中将 IWebHost 改为 IWebHostBuilder 

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>();
}

在 Startup 中添加 SetCompatibilityVersion

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
摘自:https://www.cnblogs.com/dudu/p/9009295.html

相关文章:

  • 2021-05-26
  • 2020-02-27
  • 2022-01-09
  • 2022-12-23
  • 2021-07-04
  • 2018-02-09
猜你喜欢
  • 2021-10-28
  • 2021-10-02
  • 2021-12-16
  • 2018-05-31
  • 2021-07-31
  • 2021-05-20
相关资源
相似解决方案