无法找到包 Microsoft.VisualStudio.Azure.Containers.Tools.Targets

问题描述 投票:0回答:1

我正在尝试获取 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.

我尝试检查包源的配置,但没有发现某些问题。

.net asp.net-core .net-core nuget nuget-package
1个回答
0
投票

从错误消息中我可以看到块恢复正在尝试从以下位置恢复您的软件包:

GET https://packagesource/FindPackagesById()?

所以我的猜测是你的包来源不正确。当您运行此 cmd 命令时:

dotnet nuget list source
您应该看到
nuget.org
和地址: https://api.nuget.org/v3/index.json,如果不是这种情况,您应该添加 NuGet 作为包源:

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

然后尝试恢复您的包。

© www.soinside.com 2019 - 2024. All rights reserved.