【问题标题】:Cannot publishing a NuGet to TFS 2017无法将 NuGet 发布到 TFS 2017
【发布时间】:2017-05-06 18:29:25
【问题描述】:

当我尝试使用构建步骤将 NuGet 发布到本地 TFS 2017 时,我收到以下错误消息:

2016-12-21T09:33:58.3510841Z [command]C:\Windows\system32\chcp.com 65001
2016-12-21T09:33:58.3667084Z Active code page: 65001
2016-12-21T09:34:00.7730379Z Detected NuGet version 3.3.0.212 / 3.3.0
2016-12-21T09:34:00.7730379Z SYSTEMVSSCONNECTION exists true
2016-12-21T09:34:00.7886681Z [command]C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe push -NonInteractive C:\Agent\_work\1\s\Foo.1.4.3-build-20161221-1.nupkg -Source http://myServer:8080/tfs/My%20Team%20Projects/_packaging/our-nuget/nuget/v3/index.json -ApiKey VSTS -Verbosity Detailed
2016-12-21T09:34:01.4761938Z Please provide credentials for: http://myserver:8080/tfs/My%20Team%20Projects/_packaging/our-nuget/nuget/v3/index.json
2016-12-21T09:34:01.4761938Z UserName: System.InvalidOperationException: Cannot prompt for input in non-interactive mode.
2016-12-21T09:34:01.5074440Z ##[error]Error: C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe failed with return code: 1
2016-12-21T09:34:01.5074440Z ##[error]Packages failed to publish

我还尝试从 PowerShell 脚本运行 NuGet.exe push ... 命令作为构建步骤,但也失败了。

当我在普通的 PowerShell 控制台中手动运行它时,它可以正常运行。

从控制台运行它与在构建步骤中运行它的运行时区别是什么?如何让它发挥作用?

编辑 1 我已更改为 NuGet 3.5 并创建了详细日志。如下图:

agent.workFolder=C:\Agent\_work
loading inputs and endpoints
loading ENDPOINT_AUTH_$/
loading ENDPOINT_AUTH_PARAMETER_$/_ACCESSTOKEN
loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
loading ENDPOINT_AUTH_SCHEME_$/
loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
loading INPUT_FEEDNAME
loading INPUT_NUGETFEEDTYPE
loading INPUT_NUGETVERSION
loading INPUT_SEARCHPATTERN
loading INPUT_VERBOSITY
loaded 11
check path : C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\task.json
set resource file to: C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\task.json
system.culture=en-US
check path : C:\Windows\system32\chcp.com
C:\Windows\system32\chcp.com=C:\Windows\system32\chcp.com
C:\Windows\system32\chcp.com arg: ["65001"]
exec tool: C:\Windows\system32\chcp.com
Arguments:
65001
C:\Windows\system32\chcp.com 65001
Active code page: 65001
searchPattern=C:\Agent\_work\1\s\**\*.nupkg;-:**\packages\**\*.nupkg;-:**\*.symbols.nupkg
System.DefaultWorkingDirectory=C:\Agent\_work\1\s
pattern: C:\Agent\_work\1\s\**\*.nupkg, isNegative: false
Matching glob pattern: C:\Agent\_work\1\s\**\*.nupkg
Index of first wildcard: 19
find root dir: C:\Agent\_work\1
find C:\Agent\_work\1
4456 matches.
pattern: C:\Agent\_work\1\s\**\packages\**\*.nupkg, isNegative: true
Matching glob pattern: C:\Agent\_work\1\s\**\packages\**\*.nupkg
Index of first wildcard: 19
find root dir: C:\Agent\_work\1
find C:\Agent\_work\1
4456 matches.
pattern: C:\Agent\_work\1\s\**\*.symbols.nupkg, isNegative: true
Matching glob pattern: C:\Agent\_work\1\s\**\*.symbols.nupkg
Index of first wildcard: 19
find root dir: C:\Agent\_work\1
find C:\Agent\_work\1
4456 matches.
connectedServiceName=null
feedName=http://sag-s02:8080/tfs/SAG%20Team%20Projects/_packaging/sag-nuget/nuget/v3/index.json
nuGetAdditionalArgs=null
verbosity=Detailed
nuGetFeedType=internal
nuGetPath=null
nuGetversion=3.5.0.1829
Agent.HomeDirectory=C:\Agent
looking for tool NuGet
looking for tool variant NuGet.exe
checking C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe
SYSTEMVSSCONNECTION=http://sag-s02:8080/tfs/SAG Team Projects/
Detected NuGet version 3.5.0.1938 / 3.5.0
Quirks for 3.5.0.1938:
NoTfsOnPremAuthConfig
NuGet.ForceEnableCredentialProvider=undefined
NuGetTasks.IsHostedTestEnvironment=undefined
System.TeamFoundationCollectionUri=http://sag-s02:8080/tfs/SAG%20Team%20Projects/
Credential provider is enabled.
NuGet.ForceEnableCredentialConfig=undefined
NuGetTasks.IsHostedTestEnvironment=undefined
System.TeamFoundationCollectionUri=http://sag-s02:8080/tfs/SAG%20Team%20Projects/
Credential config is disabled due to on-prem quirks.
Getting credentials for local feeds
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
Got auth token
discovered URL prefixes: http://sag-s02:8080/tfs/SAG Team Projects/
NuGetTasks.ExtraUrlPrefixesForTesting=undefined
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe arg: push
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe arg: -NonInteractive
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe pathArg: C:\Agent\_work\1\s\Foo.1.4.3-build-20161222-5.nupkg
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe arg: C:\Agent\_work\1\s\Foo.1.4.3-build-20161222-5.nupkg
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe arg: ["-Source","http://sag-s02:8080/tfs/SAG%20Team%20Projects/_packaging/sag-nuget/nuget/v3/index.json"]
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe arg: ["-ApiKey","VSTS"]
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe arg: -Verbosity
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe arg: Detailed
credProviderPath = C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet
exec tool: C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe
Arguments:
push
-NonInteractive
C:\Agent\_work\1\s\Foo.1.4.3-build-20161222-5.nupkg
-Source
http://sag-s02:8080/tfs/SAG%20Team%20Projects/_packaging/sag-nuget/nuget/v3/index.json
-ApiKey
VSTS
-Verbosity
Detailed
C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe push -NonInteractive C:\Agent\_work\1\s\Foo.1.4.3-build-20161222-5.nupkg -Source http://sag-s02:8080/tfs/SAG%20Team%20Projects/_packaging/sag-nuget/nuget/v3/index.json -ApiKey VSTS -Verbosity Detailed
NuGet Version: 3.5.0.1938
System.AggregateException: One or more errors occurred. ---> NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source http://sag-s02:8080/tfs/SAG%20Team%20Projects/_packaging/sag-nuget/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://sag-s02:8080/tfs/SAG%20Team%20Projects/_packaging/sag-nuget/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()<---
rc:1
success:false
Error: C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
Processed: ##vso[task.issue type=error;]Error: C:\Agent\_work\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.21\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
task result: Failed
Packages failed to publish
Processed: ##vso[task.issue type=error;]Packages failed to publish
Processed: ##vso[task.complete result=Failed;]Packages failed to publish

【问题讨论】:

  • 为什么不使用 NuGet Publisher 构建步骤? visualstudio.com/en-us/docs/build/steps/package/nuget-publisher
  • 我就是这样做的,但它不起作用。
  • nuget.config (%ProgramData%\NuGet\Config) 的详细代码是什么?如果您使用 ClearTextPassword,结果是什么。例如: packageSourceCredentials>
  • %ProgramData%\NuGet\Config 中没有 nuget.config :-(
  • 我可以使用 Nuget 3.5 重现此问题,但 3.3 可以正常工作。使用 3.3 发布包时是否使用内部 Nuget Feed?

标签: tfs nuget tfsbuild nuget-package


【解决方案1】:

以下错误提示你需要提供凭证才能推送包:

Please provide credentials for: http://myserver:8080/tfs/My%20Team%20Projects/_packaging/our-nuget/nuget/v3/index.json
UserName: System.InvalidOperationException: Cannot prompt for input in non-interactive mode.

检查解决方案here:以将运行构建的用户身份登录,并使用密码更新 nuget 源引用(将在用户特定的 appdata 配置文件中):

nuget sources update -Name <whatever you called it> -source http://your.nuget.repo/authed/feed/ -User <your username> -pass <your pwd>

这会将加密的密码保存在该计算机上用户特定的配置文件中,这意味着您不会再收到输入该来源的提示。

这里有更多选项的详细信息:http://www.xavierdecoster.com/nuget-package-restore-from-a-secured-feed

【讨论】:

  • 我已经对此进行了实验,但我还没有让它工作。我按照您的建议进行了操作,并将 nuget 版本更改为 3.5。使用当前错误日志查看我更新的问题
【解决方案2】:

查找原因:用户名或密码在添加Feed源时包含引号。处理该问题的解决方案:

  1. 下载 Nuget 3.5
  2. 打开命令提示符并导航到 Nuget.exe 文件夹 (CD)
  3. 通过此命令更新包源(不要在用户名和密码中包含引号):

命令:

.\nugget.exe Sources update -name '[feedname]' -source "[feed address]" -username [user name] -password [password]
  1. 队列构建以发布包

注意:不要在用户名和密码中包含引号,例如:'user1'“user1”、只需使用user1 .

【讨论】:

    猜你喜欢
    • 2018-07-01
    • 1970-01-01
    • 2017-12-09
    • 1970-01-01
    • 2018-07-24
    • 1970-01-01
    • 2018-03-03
    • 2012-02-08
    • 2017-04-07
    相关资源
    最近更新 更多