2015-03-30 147 views
8

我有TFS做一些持续集成构建。今天,它打破了一个解决方案。它似乎无法找到AutoMapper。所有其他的软件包都可以找到。TFS无法恢复NuGet包

几个相关要点:

  • 包都不是在源头控制,我们让TFS恢复它们。
  • 我们有一个内部的NuGet提要,但在其他解决方案中似乎没有问题,并且在此解决方案中,我们仍然在使用Entity Framework进行还原 - 而不是AutoMapper。
  • 我尝试删除并重新添加NuGet包。没有运气。
  • 如果我使用远程桌面连接到构建服务器并在Visual Studio中打开该项目,那么它将恢复软件包并构建正常。
  • 我可以通过执行D:\"Program Files"\"Microsoft Team Foundation Server 12.0"\Tools\Nuget.exe restore然后msbuild MySolutoin.sln
  • 手动构建我们的TFS服务器安装在我们的D:\驱动器上。

这是从TFS日志:

D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\nuget.exe restore "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" -NonInteractive 
Installing 'EntityFramework 6.1.3'. 
Installing 'InternalPackage 1.0'. 
Successfully installed 'InternalPackage 1.0'. 
Successfully installed 'EntityFramework 6.1.3'. 
Unable to find version '3.3.1' of package 'AutoMapper'. 
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" /nr:False /fl /flp:"logfile=C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true /m /p:OutDir="C:\Builds\1\MyCompany Web\FclQuoteWcfService\bin\\" /p:VCBuildOverride="C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln.vsprops" /dl:WorkflowCentralLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/230;IgnoreDuplicateProjects=False;InformationNodeId=12;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://ctidev2k8:8080/tfs/MyCompany;"*WorkflowForwardingLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;" /p:BuildId="9aa9f8af-c9b9-4d0a-ba06-7cc959231d8e,vstfs:///Build/Build/230" /p:BuildLabel="FclQuoteWcfService_20150330.2" /p:BuildTimestamp="Mon, 30 Mar 2015 20:40:07 GMT" /p:BuildSourceVersion="[email protected]$/MyCompany Web" /p:BuildDefinition="FclQuoteWcfService" 
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) 
+0

您是否仅从构建服务器上的内部NuGet源恢复?或者你还允许从nuget.org恢复?如果没有,那么检查包装是否在你的内部饲料中。另外,在手动运行构建时,您可能会以不同的访问权限不同的用户(以及不同的nuget.config全局文件,以及不同的nuget存储库)运行。 – Petrik 2015-04-13 21:15:49

回答

10

我已经看到了这一点。一旦NuGet包恢复切换到内部馈送,它似乎就会被触发。一旦这样做,这是不会切换回官方nuget.org饲料,并继续寻找内部饲料的包。

确保两个软件包源都添加到您的NuGet.config文件中。同时确保两个来源都是“有效”的。

<configuration> 
    <packageSources> 
     <add key="nuget.org" 
      value="https://www.nuget.org/api/v2/" /> 
     <add key="example.com" 
      value="http://example.com/feed/nuget/" /> 
    </packageSources> 
    <activePackageSource> 
     <add key="All" 
      value="(Aggregate source)" /> 
    </activePackageSource> 
</configuration> 

请参阅NuGet configuration file文档。

0

除了马特的答案,我想从的NuGet文档突出以下以及隐藏的东西:

的NuGet配置文件在以下优先顺序 处理(最接近文件夹的NuGet .EXE从胜运行),例如假设 溶液目录是c:\a\b\c

  • c:\a\b\c\.nuget\nuget.config - 该文件仅用于溶液 水平p ackages,而不是在的NuGet 3.0支持 - 3.4
  • c:\a\b\c\nuget.config
  • c:\a\b\nuget.config
  • c:\a\nuget.config
  • c:\nuget.config
  • 用户特定的配置文件, %AppData%\NuGet\nuget.config
  • 或用户指定的文件通过选项 -ConfigFile

这可以解释在特定场景中的一些奇怪的行为,其中一个恢复或不拿起配置饲料,这取决于无论您用的NuGet 2.x或3.x的恢复

编辑:和我发现yet another reason why packages might not be detected

我有版本1.1.1.0包“A”。

此前3.4这个命令效果很好:

nuget install A -version 1.1.1.0

用的NuGet 3.4 RC我得到:

An error occurred while retrieving package metadata for 'A.1.1.1' from source 'N'. An error occurred while retrieving package metadata for 'A.1.1.1' from source 'N'. Data at the root level is invalid. Line 1, position 1.

...

客户把1.1,1.1 .0,1.01.0和1.1.0.0与使用SemVer规则的相同版本 秒。原因非标准化的版本是特别 套管在过去是因为V2 HTTP调用客户端完全按照用户指定那就先01​​发送版本字符串

1

马特的回答让我在正确的轨道上,但我们不使用内部饲料,所以我不得不做更多的挖掘。至少,这个答案适用于在Visual Studio 2015中创建的项目,并由TFS 2015构建。

在Visual Studio中,打开NuGet程序包管理器设置(工具菜单> NuGet程序包管理器>程序包管理器设置)。从左侧的选项列表中选择“套餐来源”。

Screenshot of the NuGet Packages Sources options window

在溶液的根目录下创建的nuget.config文件。这应该与您的“.sln”解决方案文件位于相同的文件夹位置。复制下面到配置文件:内<packageSources>标签

​​

,创建在“包源”选项窗口中列出的每个源的<add key="" value="" />条目。关键是URL的上面显示的源的名称,值是URL本身。包括“可用软件包源”和“机器范围软件包源”中列出的软件包。我没有为本地文件系统创建条目,因为它没有在此解决方案中使用。基于上面的截图,完整的配置文件现在包含以下内容:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <packageSources> 
     <add key="nuget.org" 
      value="https://api.nuget.org/v3/index.json" /> 
     <add key="Microsoft and .NET" 
      value="https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/" /> 
    </packageSources> 
    <activePackageSource> 
     <add key="All" 
      value="(Aggregate source)" /> 
    </activePackageSource> 
</configuration> 

nuget.config文件的源代码控制后,TFS能够下载所有必要的NuGet包,并成功地构建解决方案。