【问题标题】:Installing a NuGet package from command-line from a private feed从私有源的命令行安装 NuGet 包
【发布时间】:2014-10-28 04:18:01
【问题描述】:

是否可以从脚本中的私人提要(即需要登录名/密码)获取 NuGet 包?

我有一个带有单个 JSON 文件的 NuGet 包。它托管在私人 TeamCity 提要上。我想在脚本中使用那个 JSON,所以这就是我想要做的:

nuget sources add -Name tc -Source https://xxxxxxxxx/ -Username username -Password password
nuget install xxxxxxxx -source tc
nuget sources remove -Name tc

这会导致Unable to find version '1.0.7' of package 'xxxxxxx'. 这很奇怪,因为它显然能够访问提要,因为它看到了包的版本,但无法下载包。

我还尝试将包安装到虚拟 .sln 中并运行 nuget restore xxxxx.sln。然后 NuGet 两次要求我提供凭据:

Please provide credentials for: https://xxxxxxxx/httpAuth/app/nuget/v1/xxxxx.svc/
Please provide credentials for: https://xxxxxxxx/httpAuth/repository/download/xxxxx/1148145:id/xxxxxxxx.1.0.7.nupkg

使用提要和凭据声明创建 NuGet.config 也会导致相同的 Unable to find 错误。

当我从 VS 安装/恢复包时,它工作正常。

这两个问题似乎相关:

【问题讨论】:

  • 您使用的是哪个版本的 NuGet.exe?使用最新的 NuGet.exe 2.8.2 (2.8.50506.491) 但使用 2.8.1 (2.8.50320.36) 时,我在 Team City 上的还原遇到了类似的问题。

标签: nuget


【解决方案1】:

看来是 TC Feed 有问题。我不认为是这种情况,因为我可以使用 VS 包管理器的提要,问题仅在于命令行 NuGet。

我打开了-Verbosity detailed (thanks danliu),这是我看到的:

GET https://xxxxxx/httpAuth/app/nuget/v1/FeedService.svc/Packages(Id='xxxxxx',Version='1.0.7')
GET https://xxxxxx/httpAuth/app/nuget/v1/FeedService.svc/Packages(Id='xxxxxx',Version='1.0.7.0')
System.InvalidOperationException: Unable to find version '1.0.7' of package 'xxxxxx'.

请求GET https://xxxxxx/httpAuth/app/nuget/v1/FeedService.svc/Packages(Id='xxxxxx',Version='1.0.7')返回404,我认为这与TeamCity NuGet提要设置中提到的服务器配置问题有关:

NuGet Feed must contain server URL inside. Current TeamCity server configuration does not let TeamCity server to get original request URL from HTTP request. It looks like TeamCity server is wrongly configured with reverse proxy. Make sure reverse proxy and TeamCity server is configured to let TeamCity server know request real request URL.

我尝试在 MyGet 上托管该软件包并从那里安装它。成功了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多