当前位置: 动力学知识库 > 问答 > 编程问答 >

visual studio 2013 - Nuget.exe: An existing connection was forcibly closed by the remote host

问题描述:

On my build server in my prebuild script I want to get all packages required for the solution.

Why? Because this happens:

This project references NuGet package(s) that are missing on this computer.

Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.

The missing file is ..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets.

According to Nuget documentation package restore should happen as part of the TFS 2013 build - but quite obviously it does not.

I tried to implement this as a prebuild action (custom script execution).

Whenever I try to run nuget on the build server this is what happens:

PS D:\ws\more\txs04\Data\Services\MyProject\.nuget> .\nuget.exe

An existing connection was forcibly closed by the remote host

Obviously a proxy issue. Unfortunately I didn't find any solution for this. I logged on as the build user and changed the proxy settings. I also tried environment variables - and the nuget configuration options. However since I cannot even invoke nuget.exe config this is kind of not an option.

Edit: I can reproduce this behavior on my development machine (where nuget usually works). runas /user:dev\tfsbuild powershell Next I try to execute nuget.exe and the above mentioned error occurs. It does not occur if I login with the tfsbuild user however.

网友答案:

I was having a similar issue running the nuget restore command from a target in my build .proj file.

 <Target Name="RestorePackages">
   <Exec Command="&quot;$(ToolsHome)NuGet\NuGet.exe&quot; restore &quot;$(SourceHome)SolutionFile.sln&quot;" />
 </Target>

I added two additional parameters which resolved the issue for me: -NonInteractive -RequireConsent

<Target Name="RestorePackages">
  <Exec Command="&quot;$(ToolsHome)NuGet\NuGet.exe&quot; restore &quot;$(SourceHome)SolutionFile.sln&quot; -NonInteractive -RequireConsent " />
</Target>

Hope this helps anyone else that runs into this.

分享给朋友:
您可能感兴趣的文章:
随机阅读: