使用 NuGet 上游源的 Azure DevOps 工件提要安装包失败
Install-Package with Azure DevOps Artifacts feed with NuGet upstream source is failing
问题
我正在尝试从 public 存储库安装一个包。我想使用 PackageSource External
。这是一个 Azure DevOps Artifacts Feed,配置了 NuGet Gallery 作为 Upstream source
。由于 NuGet Gallery 是上游源,我对包的请求应该通过 Artifacts 并由上游源完成,但它却出错并说没有匹配项。
另一方面,如果我使用直接指向 NuGet Gallery 的 PackageSource 提交相同的请求,它就可以工作。 Artifacts 中的上游源代码功能会被破坏吗?
包源
[D:\MySandboxes\TFS\Development\DevOps\]
>Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
Microsoft Visual Studio Offli... NuGet False C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Internal NuGet False http://azuredevops/Development/_packaging/Internal/nuget/v3/index.json
External NuGet False http://azuredevops/Development/_packaging/External/nuget/v3/index.json
MyNuGet NuGet False https://www.nuget.org/api/v2
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
使用 Azure DevOps Artifacts 包源安装包(失败)
[D:\MySandboxes\TFS\Development\DevOps\]
>Install-Package Resta.UriTemplates -Source External -Destination "."
Install-Package : No match was found for the specified search criteria and package name 'Resta.UriTemplates'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Resta.UriTemplates -Source External -Destination "."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
正在使用 NuGet Gallery 包源安装包(成功)
[D:\MySandboxes\TFS\Development\DevOps\]
>Install-Package Resta.UriTemplates -Source MyNuGet -Destination "."
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'MyNuGet'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "No"): a
Name Version Source Summary
---- ------- ------ -------
Resta.UriTemplates 1.3.0 MyNuGet .NET implementation of the URI template spec (RFC6570). Supports up to level 4 template expressions.
上游源代码功能在我这边运行良好。但是,我在安装包时没有得到这个促销信息。
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'MyNuGet'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "No"): a
这似乎与您本地的安全设置有关。不知道如何启用或禁用。不过根据你的描述和情况。在我看来,我想知道在使用 Azure DevOps Artifacts 包源安装包时是否有跳转。
由于与直接连接 NuGet Gallery 不同,您需要先访问 Azure DevOps Artifacts Feed,然后通过上游源获取该包。您不能 select 信任信息,它选择默认值(默认值是 "No")。最后,您无法安装该软件包。
您可以关闭本地安全设置并重试,这可能会奏效。如果由于政策原因,您无法将其关闭。
作为解决方法,您可以创建一个关闭上游的需求源,并将您的包作为包源上传到源中。
所以在做了一些额外的测试之后,我确实发现使用 nuget.exe
CLI 可以在 Install-Command
cmdlet 使我失败的地方工作。
不幸的是,我仍然不完全确定为什么会发生这种行为。
下面是我的版本Install-Package
>Get-Command -name 'Install-Package'
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Install-Package 1.4.3 PackageManagement
还有我的版本nuget.exe
>nuget
NuGet Version: 5.2.0.6090
最后,这是 nuget.exe
命令成功的输出。
[C:\Users\srz\]
>nuget install Microsoft.Extensions.Primitives -Version 3.0.1 -Source "External"
Feeds used:
C:\Users\srz\.nuget\packages\
http://azuredevops/Development/_packaging/External/nuget/v3/index.json
Attempting to gather dependency information for package 'Microsoft.Extensions.Primitives.3.0.1' with respect to project 'C:\Users\srz', targeting 'Any,Version=v0.0'
Gathering dependency information took 651.6 ms
Attempting to resolve dependencies for package 'Microsoft.Extensions.Primitives.3.0.1' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.Extensions.Primitives.3.0.1'
Resolved actions to install package 'Microsoft.Extensions.Primitives.3.0.1'
Retrieving package 'Microsoft.Extensions.Primitives 3.0.1' from 'External'.
GET http://azuredevops/Development/_packaging/abc123/nuget/v3/flat2/microsoft.extensions.primitives/3.0.1/microsoft.extensions.primitives.3.0.1.nupkg
OK http://azuredevops/Development/_packaging/abc123/nuget/v3/flat2/microsoft.extensions.primitives/3.0.1/microsoft.extensions.primitives.3.0.1.nupkg 229ms
Installing Microsoft.Extensions.Primitives 3.0.1.
Adding package 'Microsoft.Extensions.Primitives.3.0.1' to folder 'C:\Users\srz'
Added package 'Microsoft.Extensions.Primitives.3.0.1' to folder 'C:\Users\srz'
Successfully installed 'Microsoft.Extensions.Primitives 3.0.1' to C:\Users\srz
Executing nuget actions took 635.5 ms
问题
我正在尝试从 public 存储库安装一个包。我想使用 PackageSource External
。这是一个 Azure DevOps Artifacts Feed,配置了 NuGet Gallery 作为 Upstream source
。由于 NuGet Gallery 是上游源,我对包的请求应该通过 Artifacts 并由上游源完成,但它却出错并说没有匹配项。
另一方面,如果我使用直接指向 NuGet Gallery 的 PackageSource 提交相同的请求,它就可以工作。 Artifacts 中的上游源代码功能会被破坏吗?
包源
[D:\MySandboxes\TFS\Development\DevOps\]
>Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
Microsoft Visual Studio Offli... NuGet False C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Internal NuGet False http://azuredevops/Development/_packaging/Internal/nuget/v3/index.json
External NuGet False http://azuredevops/Development/_packaging/External/nuget/v3/index.json
MyNuGet NuGet False https://www.nuget.org/api/v2
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
使用 Azure DevOps Artifacts 包源安装包(失败)
[D:\MySandboxes\TFS\Development\DevOps\]
>Install-Package Resta.UriTemplates -Source External -Destination "."
Install-Package : No match was found for the specified search criteria and package name 'Resta.UriTemplates'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Resta.UriTemplates -Source External -Destination "."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
正在使用 NuGet Gallery 包源安装包(成功)
[D:\MySandboxes\TFS\Development\DevOps\]
>Install-Package Resta.UriTemplates -Source MyNuGet -Destination "."
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'MyNuGet'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "No"): a
Name Version Source Summary
---- ------- ------ -------
Resta.UriTemplates 1.3.0 MyNuGet .NET implementation of the URI template spec (RFC6570). Supports up to level 4 template expressions.
上游源代码功能在我这边运行良好。但是,我在安装包时没有得到这个促销信息。
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'MyNuGet'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "No"): a
这似乎与您本地的安全设置有关。不知道如何启用或禁用。不过根据你的描述和情况。在我看来,我想知道在使用 Azure DevOps Artifacts 包源安装包时是否有跳转。
由于与直接连接 NuGet Gallery 不同,您需要先访问 Azure DevOps Artifacts Feed,然后通过上游源获取该包。您不能 select 信任信息,它选择默认值(默认值是 "No")。最后,您无法安装该软件包。
您可以关闭本地安全设置并重试,这可能会奏效。如果由于政策原因,您无法将其关闭。
作为解决方法,您可以创建一个关闭上游的需求源,并将您的包作为包源上传到源中。
所以在做了一些额外的测试之后,我确实发现使用 nuget.exe
CLI 可以在 Install-Command
cmdlet 使我失败的地方工作。
不幸的是,我仍然不完全确定为什么会发生这种行为。
下面是我的版本Install-Package
>Get-Command -name 'Install-Package'
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Install-Package 1.4.3 PackageManagement
还有我的版本nuget.exe
>nuget
NuGet Version: 5.2.0.6090
最后,这是 nuget.exe
命令成功的输出。
[C:\Users\srz\]
>nuget install Microsoft.Extensions.Primitives -Version 3.0.1 -Source "External"
Feeds used:
C:\Users\srz\.nuget\packages\
http://azuredevops/Development/_packaging/External/nuget/v3/index.json
Attempting to gather dependency information for package 'Microsoft.Extensions.Primitives.3.0.1' with respect to project 'C:\Users\srz', targeting 'Any,Version=v0.0'
Gathering dependency information took 651.6 ms
Attempting to resolve dependencies for package 'Microsoft.Extensions.Primitives.3.0.1' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.Extensions.Primitives.3.0.1'
Resolved actions to install package 'Microsoft.Extensions.Primitives.3.0.1'
Retrieving package 'Microsoft.Extensions.Primitives 3.0.1' from 'External'.
GET http://azuredevops/Development/_packaging/abc123/nuget/v3/flat2/microsoft.extensions.primitives/3.0.1/microsoft.extensions.primitives.3.0.1.nupkg
OK http://azuredevops/Development/_packaging/abc123/nuget/v3/flat2/microsoft.extensions.primitives/3.0.1/microsoft.extensions.primitives.3.0.1.nupkg 229ms
Installing Microsoft.Extensions.Primitives 3.0.1.
Adding package 'Microsoft.Extensions.Primitives.3.0.1' to folder 'C:\Users\srz'
Added package 'Microsoft.Extensions.Primitives.3.0.1' to folder 'C:\Users\srz'
Successfully installed 'Microsoft.Extensions.Primitives 3.0.1' to C:\Users\srz
Executing nuget actions took 635.5 ms