nuget恢复团队服务构建失败

时间:2017-09-07 22:17:21

标签: visual-studio-2017 azure-pipelines nuget-package-restore

我在asp.net核心解决方案上使用vs2017通过nuget引用了2个本地程序集(打包了dll),在本地构建良好。

现在尝试通过VSTS生成构建我收到以下错误,

Detected NuGet version 4.0.0.2283 / 4.0.0
SYSTEMVSSCONNECTION exists true
Saving NuGet.config to a temporary config file.
d:\a\_tool\NuGet\4.0.0\x64\nuget.exe restore d:\a\1\s\TestFrameworkCoreAPI.sln -Verbosity Detailed -NonInteractive -ConfigFile d:\a\1\Nuget\tempNuGet_37.config
NuGet Version: 4.0.0.2283
MSBuild auto-detection: using msbuild version '15.3.409.57025' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe /t:GenerateRestoreGraphFile /nologo /nr:false /p:RestoreUseCustomAfterTargets=true /p:BuildProjectReferences=false /v:q  /p:NuGetRestoreTargets="d:\a\_temp\NuGet-Scratch\w53qa5rr.4sd.targets" /p:RestoreTaskAssemblyFile="d:\a\_tool\NuGet\4.0.0\x64\nuget.exe" /p:RestoreGraphOutputPath="d:\a\_temp\NuGet-Scratch\4mlmlfgh.mmy.result" /p:ExcludeRestorePackageImports=true  /p:RestoreRecursive=False  /p:RestoreProjectFilterMode=exclusionlist /p:RestoreContinueOnError=WarnAndContinue  /p:RestoreGraphProjectInput="d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj;" "d:\a\_temp\NuGet-Scratch\w53qa5rr.4sd.targets"
Running restore with 2 concurrent jobs.
Reading project file d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj.
Reading project file d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj.
Restoring packages for d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj...
Restoring packages for d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj...
Restoring packages for .NETCoreApp,Version=v1.1...
Restoring packages for .NETCoreApp,Version=v2.0...
System.AggregateException: One or more errors occurred. ---> NuGet.Protocol.Core.Types.FatalProtocolException: Failed to retrieve information about 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' from remote source 'D:\TestFrameworkAssemblies'.
   at NuGet.Protocol.LocalV3FindPackageByIdResource.GetVersionsCore(String id, ILogger logger)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at NuGet.Protocol.LocalV3FindPackageByIdResource.GetAllVersionsAsync(String id, SourceCacheContext cacheContext, ILogger logger, CancellationToken token)
   at NuGet.Commands.SourceRepositoryDependencyProvider.<FindLibraryAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
Error: d:\a\_tool\NuGet\4.0.0\x64\nuget.exe failed with return code: 1
Packages failed to restore

我在位于解决方案根目录的.nuget文件夹中有一个nuget.config文件,

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
  <!-- remove any machine-wide sources with <clear/> -->
  <clear />
  <add key="Test Framework" value="D:\TestFrameworkAssemblies" />
  <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<activePackageSource>
    <add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>     

这是VSTS构建def,NuGet恢复步骤

中的内容

build definition

它看起来总是引用我的本地程序集而不是标准的nuget.org,现在在配置文件中,如果我取出我的本地条目到框架程序集,nuget部分可以工作,但我得到一个主要的引用错误,因为它找不到我本地打包的2个组件。

目前已经围绕这个圈子,你怎么能让VSTS恢复本地打包的程序集以及nuget.org。我也在使用Hosted 2017。

提前致谢

1 个答案:

答案 0 :(得分:2)

您似乎在托管代理上排队。由于本地计算机上有软件包,因此您应使用位于本地计算机上的private agent进行构建

此外,如果您需要在托管代理上对构建进行排队,则应在存储库中添加本地软件包,然后使用新路径引用软件包并更改nuget.config中的值。