TFS2017 - 使用 octopack 凭据进行 NuGet 推送

Posted

技术标签:

【中文标题】TFS2017 - 使用 octopack 凭据进行 NuGet 推送【英文标题】:TFS2017 - NuGet push with octopack credentials 【发布时间】:2017-04-05 09:30:54 【问题描述】:

我在将我的包推送到我使用 TFS2017 包选项卡创建的内部 NuGet 提要时遇到问题。

我收到以下错误:

2017-04-05T09:08:24.8336348Z      6>OctoPack:
2017-04-05T09:08:24.8336348Z          Please provide credentials for: http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json
2017-04-05T09:08:24.9273850Z          Unable to load the service index for source http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json.
2017-04-05T09:08:24.9273850Z            Response status code does not indicate success: 401 (Unauthorized).
2017-04-05T09:08:24.9273850Z          UserName: Password: 
2017-04-05T09:08:24.9430236Z ##[error]Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): Error MSB3073: The command ""C:\TFS_Agents\Product_Agent_1\_work\2\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:\TFS_Agents\Product_Agent_1\_work\2\s\Source\Company.Product.ServiceBus\obj\octopacked\Company.Product.ServiceBus.Release.3.5.0.nupkg"  -Source http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json " exited with code 1.
2017-04-05T09:08:24.9430236Z      6>C:\TFS_Agents\Product_Agent_1\_work\2\s\Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): error MSB3073: The command ""C:\TFS_Agents\Product_Agent_1\_work\2\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:\TFS_Agents\Product_Agent_1\_work\2\s\Source\Company.Product.ServiceBus\obj\octopacked\Company.Product.ServiceBus.Release.3.5.0.nupkg"  -Source http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json " exited with code 1. [C:\TFS_Agents\Product_Agent_1\_work\2\s\Source\Company.Product.ServiceBus\Company.Product.ServiceBus.csproj]

我想使用 OctoPack 使用以下构建参数将包推送到它:

/p:RunOctoPack=true 
/p:OctoPackPublishPackageToHttp=http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json 
/p:OctoPackAppendToPackageId=Release 
/p:OctoPackNuGetProperties=Configuration=Release

我尝试使用以下方法:

/p:OctoPackPublishApiKey=VSTS
/p:OctoPackNuGetPushProperties=-ApiKey=VSTS

两个参数都不起作用..

我也不介意从提要中删除 apikey / 凭据,但在 TFS 2017 的新包功能中实际上没有文档说明如何执行此操作。

这是我刚刚在 nuget 推送参数中使用 -Verbosity detailed 打印出来的堆栈跟踪:

  OctoPack: OctoPack successful
  Publish to repository: http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json
  "C:\********_Agents\Product_Agent_1\_work\7\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:\********_Agents\Product_Agent_1\_work\7\s\Source\Company.Product.ApiProxy.v2\obj\octopacked\Company.Product.ApiProxy.v2.Release.3.5.0.nupkg"  -Source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json -Verbosity detailed -ApiKey key
  NuGet Version: 3.5.0.10252 (Custom build for OctoPack)
  Please provide credentials for: http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json
  System.AggregateException: One or more errors occurred. ---> NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
     at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
     at NuGet.Protocol.HttpSource.<>c__DisplayClass12_0.<<GetAsync>b__0>d.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__2`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.HttpSource.<GetAsync>d__12.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
     at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
     --- End of inner exception stack trace ---
     at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.ServiceIndexResourceV3Provider.<TryCreate>d__8.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.PackageUpdateResourceV3Provider.<TryCreate>d__1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__15`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Commands.CommandRunnerUtility.<GetPackageUpdateResource>d__3.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Commands.PushRunner.<Run>d__0.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.CommandLine.PushCommand.<ExecuteCommandAsync>d__28.MoveNext()
     --- End of inner exception stack trace ---
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
     at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
     at NuGet.CommandLine.Command.Execute()
     at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
  ---> (Inner Exception #0) NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
     at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
     at NuGet.Protocol.HttpSource.<>c__DisplayClass12_0.<<GetAsync>b__0>d.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__2`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.HttpSource.<GetAsync>d__12.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
     at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
     --- End of inner exception stack trace ---
     at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.ServiceIndexResourceV3Provider.<TryCreate>d__8.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.PackageUpdateResourceV3Provider.<TryCreate>d__1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__15`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Commands.CommandRunnerUtility.<GetPackageUpdateResource>d__3.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.Commands.PushRunner.<Run>d__0.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at NuGet.CommandLine.PushCommand.<ExecuteCommandAsync>d__28.MoveNext()<---

  UserName: Password: 
Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): Error MSB3073: The command ""C:\********_Agents\Product_Agent_1\_work\7\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:\********_Agents\Product_Agent_1\_work\7\s\Source\Company.Product.ApiProxy.v2\obj\octopacked\Company.Product.ApiProxy.v2.Release.3.5.0.nupkg" -Source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json -Verbosity detailed -ApiKey key" exited with code 1.
C:\********_Agents\Product_Agent_1\_work\7\s\Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): error MSB3073: The command ""C:\********_Agents\Product_Agent_1\_work\7\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:\********_Agents\Product_Agent_1\_work\7\s\Source\Company.Product.ApiProxy.v2\obj\octopacked\Company.Product.ApiProxy.v2.Release.3.5.0.nupkg"  -Source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json -Verbosity detailed -ApiKey key" exited with code 1. [C:\********_Agents\Product_Agent_1\_work\7\s\Source\Company.Product.ApiProxy.v2\Company.Product.ApiProxy.v2.csproj]
Done Building Project "C:\********_Agents\Product_Agent_1\_work\7\s\Source\Company.Product.ApiProxy.v2\Company.Product.ApiProxy.v2.csproj" (default targets) -- FAILED.
Project "C:\********_Agents\Product_Agent_1\_work\7\s\Source\Company.Product.Solution.sln" (1) is building "C:\********_Agents\Product_Agent_1\_work\7\s\Source\Company.Product.ApiProxy.v2.TestConsole\Company.Product.ApiProxy.v2.TestConsole.csproj" (24) on node 1 (default targets).

【问题讨论】:

仍有问题...(编辑) 【参考方案1】:

如果你打开命令行并执行它是否有效

nuget push foo.nupkg your-api-key -source http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json

【讨论】:

以上是关于TFS2017 - 使用 octopack 凭据进行 NuGet 推送的主要内容,如果未能解决你的问题,请参考以下文章

OctoPack 和 OD 通道:如何创建可以通过管道传输到版本通道的包版本?

TFS 2017 版本 - 没有机器组和部署组

从 XML 文件中读取网络凭据以连接到 TFS 服务器

Octopack 工件包括源代码

AppVeyor Octopack - GetAssemblyVersion 失败

如何在octopack中使用nuspec中设置的版本号?