【问题标题】: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 中尝试了几个设置,但没有任何效果

我能做些什么?

【问题讨论】:

  • 显示你的 startup.cs 文件代码
  • @viveknuna 我回复了

标签: 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; }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-04
    • 1970-01-01
    • 1970-01-01
    • 2023-01-28
    相关资源
    最近更新 更多