带有NuGet上游源的Azure DevOps Artifacts feed的安装包失败

时间:2019-11-20 21:16:15

标签: powershell tfs azure-devops nuget azure-artifacts

问题

我正在尝试从公共存储库安装软件包。我想使用PackageSource External。这是 Azure DevOps工件提要,已将 NuGet Gallery 配置为Upstream source。由于NuGet Gallery是上游资源,因此我对软件包的请求应通过Artifacts并由上游资源来满足,但会出现错误并指出没有匹配项。

另一方面,如果我使用直接指向NuGet Gallery的PackageSource提交相同的请求,则它可以工作。可以破坏工件中的上游源功能吗?


enter image description here

包裹来源

[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.

2 个答案:

答案 0 :(得分:1)

上游源功能在我这方面效果很好。但是,在安装软件包期间我没有得到此促销信息。

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,然后再通过上游源访问该包。您无法选择信任信息,而是选择默认值(默认为“否”)。最后,您无法安装该软件包。

您可以关闭本地安全设置,然后重试,这可能会起作用。如果由于政策原因,您无法将其关闭。

作为一种解决方法,您可以在上游关闭的情况下创建一个需要的Feed,并将您的软件包作为Feed来源上传到Feed中。

答案 1 :(得分:0)

因此,在进行了一些额外的测试之后,我确实发现,在nuget.exe cmdlet使我失败的地方使用Install-Command CLI可以解决问题。

不幸的是,我仍然不确定为什么会发生这种情况。

下面是我的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