Net升级问题
1.Net5.0升级Met6.0配置
1.1 Porgram.cs文件修改
Porgram.cs的代码更换为以下代码,会出现缺少引用的错误。var builder = WebApplication.CreateBuilder(args);无需按照提示在该文件中添加suing.下一步解决问题。
var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();
1.2 项目文件修改
右键项目->编辑项目文件然后添加
此时上次缺少引用的错误就解决了。
1.3 删除Setup.cs
Net6.0只需要一个Porgram.cs,在Net5.0项目中删除Setup.cs。