且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

TFS 无法恢复 NuGet 包

更新时间:2023-02-02 17:45:48

我也见过这个.它似乎在 NuGet 包还原切换到内部提要时立即触发.一旦这样做,它就不会切换回官方 nuget.org 提要,而是继续在内部提要上查找包.

确保将两个包源都添加到您的 NuGet.config 文件中.还要确保两个来源都是活动的".

<packageSources><add key="nuget.org"value="https://www.nuget.org/api/v2/"/><add key="example.com"value="http://example.com/feed/nuget/"/></packageSources><activePackageSource><添加键=全部"value="(聚合源)"/></activePackageSource></配置>

请参阅NuGet 配置文件文档.

I've got TFS doing some continuous integration builds. Today, it broke for one solution. It seems it can't find AutoMapper. All the other packages can be found just fine.

A couple relevant points:

  • None of the packages are in source control, we're letting TFS restore them.
  • We have an internal NuGet feed, but it doesn't seem to be a problem in other solutions, and in this solution we are still getting Entity Framework to restore - just not AutoMapper.
  • I tried removing and re-adding the NuGet Packages. No luck.
  • If I use Remote Desktop to connect to the build server and open the project in Visual Studio there, it restores the packages and builds fine.
  • I can build manually by executing D:\"Program Files"\"Microsoft Team Foundation Server 12.0"\Tools\Nuget.exe restore followed by msbuild MySolutoin.sln
  • Our TFS server is installed on our D:\ drive.

This is from the TFS Logs:

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="LFclQuoteWcfService_20150330.2@$/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)

I've seen this too. It seems to be triggered as soon as NuGet package restore switches to the internal feed. Once it does this is doesn't switch back to the official nuget.org feed and continues to look for the packages on the internal feed.

Ensure both package sources are added to your NuGet.config file. Also ensure both sources are 'active'.

<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>

See NuGet configuration file documentation.