我试图获取swagger库,但出现以下错误,即使我创建的新项目也会出现默认错误:

dotnet add package Swashbuckle.AspNetCore --version 2.0.0

Writing C:\Users\shubham.shaw\AppData\Local\Temp\tmpoxoxul.tmp
info : X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
info : X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
info : Adding PackageReference for package 'Swashbuckle.AspNetCore' into project 'C:\Users\shubham.shaw\source\repos\JWTImplementation\JWTImplementation.csproj'.
info : Restoring packages for C:\Users\shubham.shaw\source\repos\JWTImplementation\JWTImplementation.csproj...
info :   GET https://packagesource/FindPackagesById()?id='Microsoft.VisualStudio.Azure.Containers.Tools.Targets'&semVerLevel=2.0.0
info :   GET https://packagesource/FindPackagesById()?id='Swashbuckle.AspNetCore'&semVerLevel=2.0.0
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://packagesource/FindPackagesById()?id='Swashbuckle.AspNetCore'&semVerLevel=2.0.0'.
log  : No such host is known. (packagesource:443)
log  :   No such host is known.
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://packagesource/FindPackagesById()?id='Microsoft.VisualStudio.Azure.Containers.Tools.Targets'&semVerLevel=2.0.0'.
log  : No such host is known. (packagesource:443)
log  :   No such host is known.
info :   GET https://packagesource/FindPackagesById()?id='Microsoft.VisualStudio.Azure.Containers.Tools.Targets'&semVerLevel=2.0.0
info :   GET https://packagesource/FindPackagesById()?id='Swashbuckle.AspNetCore'&semVerLevel=2.0.0
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://packagesource/FindPackagesById()?id='Microsoft.VisualStudio.Azure.Containers.Tools.Targets'&semVerLevel=2.0.0'.
log  : No such host is known. (packagesource:443)
log  :   No such host is known.
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://packagesource/FindPackagesById()?id='Swashbuckle.AspNetCore'&semVerLevel=2.0.0'.
log  : No such host is known. (packagesource:443)
log  :   No such host is known.
info :   GET https://packagesource/FindPackagesById()?id='Microsoft.VisualStudio.Azure.Containers.Tools.Targets'&semVerLevel=2.0.0
info :   GET https://packagesource/FindPackagesById()?id='Swashbuckle.AspNetCore'&semVerLevel=2.0.0
error: NU1301: Failed to retrieve information about 'Microsoft.VisualStudio.Azure.Containers.Tools.Targets' from remote source 'https://packagesource/FindPackagesById()?id='Microsoft.VisualStudio.Azure.Containers.Tools.Targets'&semVerLevel=2.0.0'.
info : Package 'Swashbuckle.AspNetCore' is compatible with all the specified frameworks in project 'C:\Users\shubham.shaw\source\repos\JWTImplementation\JWTImplementation.csproj'.
error: Value cannot be null. (Parameter 'version')


Usage: NuGet.CommandLine.XPlat.dll package add [options]

Options:
-h|--help               Show help information
--force-english-output  Forces the application to run using an invariant, English-based culture.
--package               Id of the package to be added.
--version               Version of the package to be added.
-d|--dg-file            Path to the dependency graph file to be used to restore preview and compatibility check.
-p|--project            Path to the project file.
-f|--framework          Frameworks for which the package reference should be added.
-n|--no-restore         Do not perform restore preview and compatibility check. The added package reference will be unconditional.
-s|--source             Specifies NuGet package sources to use during the restore.
--package-directory     Directory to restore packages in.
--interactive           Allow the command to block and require manual action for operations like authentication.
--prerelease            Allows prerelease packages to be installed.

我试图判断包源的配置,但没有观察到一些问题.

推荐答案

从错误消息中,我可以看到块恢复正在try 从:GET https://packagesource/FindPackagesById()?恢复您的包

因此,我的猜测是您的包来源不正确.当您运行此cmd命令:dotnet nuget list source时,您应该会看到地址为: https://api.nuget.org/v3/index.json,如果不是这样,您应该将NuGet添加为程序包源:

dotnet nuget add source  https://api.nuget.org/v3/index.json --name nuget.org

然后try 恢复您的包.

.net相关问答推荐

Powershell机器令牌组

跨请求共享数据

EF Core IEntityTypeConfigurations:从数据库提取数据后相关对象为空

如何将 select 语句详细信息提取到不同的方法中仍然保持Eager 加载?

Azure SignalR 和微服务

使用 DataDog 收集 OpenTelemetry 跟踪

PowerShell - 如果用户输入凭据,则查询 AD 时出错

SqlDateTime.MinValue != DateTime.MinValue,为什么?

.NET 应用程序的链接器状态(又名请先生,我可以有一个链接器2009 年版)

在目录中创建应用程序快捷方式

如何遍历字典并更改值?

覆盖方法上的 C# 可选参数

如何将时间设置为当天的午夜?

.NET 中是否有可序列化的通用键/值对类?

.Net 正则表达式:单词字符 \w 是什么?

场与财产.性能优化

无法加载文件或程序集System.ValueTuple

找不到库 hostpolicy.dll

如果锁定的对象内部发生异常,它会保持锁定状态吗?

SqlParameter 已被另一个 SqlParameterCollection 包含 - using() {} 作弊吗?