【问题标题】:Erro when dotnet new webapi error NU1301: Unable to load service index to source https://api.nuget.org/v3/index.json.`dotnet new webapi 错误 NU1301 时出错:无法将服务索引加载到源 https://api.nuget.org/v3/index.json。`
【发布时间】:2022-11-15 14:26:15
【问题描述】:
当我运行命令时
dotnet new wepapi
记录了以下错误
/home/.../class8.2.csproj : error NU1301: Unable to load service index to source https://api.nuget.org/v3/index.json.
我在 nuget.config 中尝试了几个设置,但没有任何效果
我能做些什么?
【问题讨论】:
标签:
c#
asp.net
.net
asp.net-core
【解决方案1】:
程序.cs
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();
天气预报.cs
namespace class8._2;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}