[英]Install-Package with Azure DevOps Artifacts feed with NuGet upstream source is failing
I'm attempting to install a package from a public repository.我正在尝试从公共存储库安装 package。 I want to use the PackageSource
External
.我想使用 PackageSource
External
。 This is a Azure DevOps Artifacts Feed that is configured with NuGet Gallery as an Upstream source
.这是一个Azure DevOps Artifacts Feed ,配置了NuGet 库作为
Upstream source
。 Since NuGet Gallery is an upstream source, my request for a package should pass through Artifacts and be fulfilled by the Upstream source, but instead it errors and says that there's no match.由于 NuGet Gallery 是上游源,我对 package 的请求应该通过 Artifacts 并由上游源实现,但它会出错并说没有匹配项。
On the other hand, if I submit the same request using a PackageSource that is pointing directly to NuGet Gallery, it works.另一方面,如果我使用直接指向 NuGet Gallery 的 PackageSource 提交相同的请求,则它可以工作。 Could the Upstream source functionality in Artifacts be broken?
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
[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
[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 Upstream source feature works well in my side.上游源功能在我这边运行良好。 However, I didn't get this promote info during install package.
但是,在安装 package 期间,我没有收到此促销信息。
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
This seems related to your local security setting.这似乎与您的本地安全设置有关。 Have no idea how to enable or disable.
不知道如何启用或禁用。 However, according to your description and situation.
不过根据你的描述和情况。 In my opinion, I was wondering if there is a jump during your installing package with Azure DevOps Artifacts package source.
在我看来,我想知道在您使用 Azure DevOps Artifacts package 源安装 package 期间是否有跳跃。
Since unlike directly connect NuGet Gallery, you need first access Azure DevOps Artifacts Feed first, then through upstream source to fetch that package.由于不像直接连接 NuGet Gallery,您需要先访问 Azure DevOps Artifacts Feed,然后通过上游源获取 package。 You could not select the trust info, it choose default (default is "No").
您不能 select 信任信息,它选择默认(默认为“否”)。 Finally, you could not install that package.
最后,您无法安装 package。
You could turn off your local security setting and try it again, which may do trick.您可以关闭本地安全设置并重试,这可能会奏效。 If due to policy, you could not turn it off.
如果由于政策原因,您无法将其关闭。
As a workaround, you could create a need feed with upstream off and upload your package in feed as package source.作为一种解决方法,您可以在上游关闭的情况下创建需求提要,并将 package 作为 package 源上传到提要中。
So after doing some additional testing, I did discover that using the nuget.exe
CLI worked where the Install-Command
cmdlet was failing me.因此,在进行了一些额外的测试之后,我确实发现使用
nuget.exe
CLI 可以在Install-Command
cmdlet 失败的情况下工作。
I'm unfortunately still not entirely sure why this behavior is happening.不幸的是,我仍然不完全确定为什么会发生这种行为。
Below is my version of Install-Package
下面是我的
Install-Package
版本
>Get-Command -name 'Install-Package'
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Install-Package 1.4.3 PackageManagement
And also my version of nuget.exe
还有我的
nuget.exe
版本
>nuget
NuGet Version: 5.2.0.6090
Finally, here's output from the nuget.exe
command succeeding.最后,这里的 output 来自
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.