Visual studio 由于缺少 nuget 包,团队服务构建失败

Visual studio team services build fails due to missing nuget packages

我刚刚在 Visual Studio Team Services 上创建了一个构建。我的购买步骤是: 1.Nuget安装程序 2. npm 安装 3. Gulp 4. Visual studio 构建

步骤 1 到 3 运行良好。如下所示,nuget 包已恢复。但是,实际构建过程失败并显示 "Error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them."。它没有给我有关丢失了哪些包裹的详细信息。我的解决方案有多个项目,但都失败了。当我手动检查他们的 packages.config 文件时,列出的包已经在 Nuget 安装程序步骤中显示成功。

2016-03-30T21:37:17.7879368Z Set workingFolder to default: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents.97.1\tasks\NuGetInstaller[=11=].1.21 
2016-03-30T21:37:17.9138636Z Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents.97.1\tasks\NuGetInstaller[=11=].1.21\NuGetInstaller.ps1 
2016-03-30T21:37:18.5920842Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents.97.1\agent\worker\tools\NuGet.exe restore "C:\a\s\ACDirectory\ACDirectory.sln"  -NonInteractive 
2016-03-30T21:37:20.2128258Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild.0\bin'. 
2016-03-30T21:37:20.6570793Z Restoring NuGet package Antlr.3.4.1.9004. 
2016-03-30T21:37:20.6580785Z Restoring NuGet package bootstrap.3.3.5. 
2016-03-30T21:37:20.7350786Z Restoring NuGet package Bootstrap-3-Typeahead.3.1.1. 
2016-03-30T21:37:20.7360787Z Restoring NuGet package Castle.Core.3.2.0. 
2016-03-30T21:37:20.7370790Z Restoring NuGet package elmah.1.2.2. 
2016-03-30T21:37:20.7370790Z Restoring NuGet package elmah.corelibrary.1.2.2. 
2016-03-30T21:37:20.7380788Z Restoring NuGet package Glimpse.1.8.6.
2016-03-30T21:37:20.7390789Z Restoring NuGet package Glimpse.Ado.1.7.3. 
2016-03-30T21:37:20.7400790Z Restoring NuGet package Glimpse.AspNet.1.8.0. 
2016-03-30T21:37:20.7400790Z Restoring NuGet package Glimpse.Mvc5.1.5.3. 
2016-03-30T21:37:20.7400790Z Restoring NuGet package Glimpse.Ninject.0.9.0. 
2016-03-30T21:37:20.7410791Z Restoring NuGet package Handlebars.Net.1.5.3. 
2016-03-30T21:37:20.7420778Z Restoring NuGet package jQuery.2.1.4. 
2016-03-30T21:37:20.7420778Z Restoring NuGet package jQuery.Validation.1.11.1. 
2016-03-30T21:37:20.7430789Z Restoring NuGet package Microsoft.AspNet.Mvc.5.2.3. 
2016-03-30T21:37:20.7440785Z Restoring NuGet package Microsoft.AspNet.Razor.3.2.3. 
2016-03-30T21:37:21.2976541Z Adding package 'elmah.1.2.2' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:21.3206242Z Added package 'elmah.1.2.2' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:21.3226250Z Restoring NuGet package Microsoft.AspNet.Web.Optimization.1.1.3. 
2016-03-30T21:37:22.1616313Z Adding package 'Bootstrap-3-Typeahead.3.1.1' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.1577504Z Adding package 'Handlebars.Net.1.5.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.1597507Z Adding package 'Glimpse.Mvc5.1.5.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2021806Z Adding package 'Microsoft.AspNet.Web.Optimization.1.1.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2081748Z Adding package 'Glimpse.Ado.1.7.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2121746Z Added package 'Handlebars.Net.1.5.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2161746Z Adding package 'Antlr.3.4.1.9004' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2191750Z Restoring NuGet package Microsoft.AspNet.WebPages.3.2.3. 
2016-03-30T21:37:23.2281754Z Added package 'Bootstrap-3-Typeahead.3.1.1' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2321829Z Adding package 'Glimpse.Ninject.0.9.0' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2401751Z Restoring NuGet package Microsoft.jQuery.Unobtrusive.Ajax.3.2.3. 
2016-03-30T21:37:23.2411755Z Added package 'Microsoft.AspNet.Web.Optimization.1.1.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2451754Z Restoring NuGet package Microsoft.jQuery.Unobtrusive.Validation.3.2.2. 
2016-03-30T21:37:23.2651757Z Added package 'Glimpse.Mvc5.1.5.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.2701752Z Restoring NuGet package Microsoft.Web.Infrastructure.1.0.0. 
2016-03-30T21:37:23.2721754Z Adding package 'elmah.corelibrary.1.2.2' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.3071730Z Added package 'Glimpse.Ninject.0.9.0' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.3111743Z Added package 'Glimpse.Ado.1.7.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.3131753Z Adding package 'Microsoft.AspNet.Razor.3.2.3' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.3171747Z Restoring NuGet package Modernizr.2.6.2. 
2016-03-30T21:37:23.3181751Z Restoring NuGet package Microsoft.Web.RedisOutputCacheProvider.1.6.5. 
2016-03-30T21:37:23.3235829Z Adding package 'jQuery.Validation.1.11.1' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.3721754Z Added package 'elmah.corelibrary.1.2.2' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.3851742Z Restoring NuGet package Newtonsoft.Json.7.0.1. 
2016-03-30T21:37:23.3861765Z Adding package 'Glimpse.AspNet.1.8.0' to folder 'C:\a\s\ACDirectory\packages' 
2016-03-30T21:37:23.3881762Z Added package 'jQuery.Validation.1.11.1' to folder 'C:\a\s\ACDirectory\packages' 

错误日志:

2016-03-30T21:19:24.6463970Z ##[error]ACDirectory\ACDirectory\ACDirectory.csproj(534,5): Error : 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 C:\a\s\ACDirectory\.nuget\NuGet.targets.    
2016-03-30T21:19:24.6463970Z      1>Project "C:\a\s\ACDirectory\ACDirectory.sln" (1) is building "C:\a\s\ACDirectory\ACDirectory\ACDirectory.csproj" (3) on node 1 (default targets).    
2016-03-30T21:19:24.6483982Z      3>C:\a\s\ACDirectory\ACDirectory\ACDirectory.csproj(534,5): error : 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 C:\a\s\ACDirectory\.nuget\NuGet.targets. 
2016-03-30T21:19:24.6683975Z ##[error]ACDirectory\ACDirectory.Model\ACDirectory.Model.csproj(136,5): Error : 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 C:\a\s\ACDirectory\.nuget\NuGet.targets. 
2016-03-30T21:19:24.6683975Z      1>Project "C:\a\s\ACDirectory\ACDirectory.sln" (1) is building "C:\a\s\ACDirectory\ACDirectory.Model\ACDirectory.Model.csproj" (2) on node 2 (default targets). 
2016-03-30T21:19:24.6693966Z      2>C:\a\s\ACDirectory\ACDirectory.Model\ACDirectory.Model.csproj(136,5): error : 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 C:\a\s\ACDirectory\.nuget\NuGet.targets. 
2016-03-30T21:19:24.6773979Z      3>_CleanRecordFileWrites: 
2016-03-30T21:19:24.6793970Z          Creating directory "obj\Release\". 
2016-03-30T21:19:24.6913977Z      3>Done Building Project "C:\a\s\ACDirectory\ACDirectory\ACDirectory.csproj" (default targets) -- FAILED. 
2016-03-30T21:19:24.6923970Z        The target "_ConvertPdbFiles" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (34,37)" does not exist in the project, and will be ignored. 
2016-03-30T21:19:24.6933982Z        The target "_CollectPdbFiles" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (34,70)" does not exist in the project, and will be ignored. 
2016-03-30T21:19:24.6953974Z        The target "_CollectMdbFiles" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (40,38)" does not exist in the project, and will be ignored. 
2016-03-30T21:19:24.6963978Z        The target "_CopyMdbFiles" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets (40,71)" does not exist in the project, and will be ignored. 
2016-03-30T21:19:24.7123978Z      2>_CleanRecordFileWrites: 
2016-03-30T21:19:24.7943968Z          Creating directory "obj\Release\". 
2016-03-30T21:19:24.8263976Z      2>Done Building Project "C:\a\s\ACDirectory\ACDirectory.Model\ACDirectory.Model.csproj" (default targets) -- FAILED. 
2016-03-30T21:19:24.8363981Z ##[error]ACDirectory\ACDirectory.SqlDAL\ACDirectory.SqlDAL.csproj(125,5): Error : 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 C:\a\s\ACDirectory\.nuget\NuGet.targets. 
2016-03-30T21:19:24.8373978Z      1>Project "C:\a\s\ACDirectory\ACDirectory.sln" (1) is building "C:\a\s\ACDirectory\ACDirectory.SqlDAL\ACDirectory.SqlDAL.csproj" (4) on node 1 (default targets). 
2016-03-30T21:19:24.8403979Z      4>C:\a\s\ACDirectory\ACDirectory.SqlDAL\ACDirectory.SqlDAL.csproj(125,5): error : 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 C:\a\s\ACDirectory\.nuget\NuGet.targets. 

尝试卸载项目并检查 .csproj 文件,看看下面是否有类似的代码段:

<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
  <PropertyGroup>
    <ErrorText>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 {0}.</ErrorText>
  </PropertyGroup>
  <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>

删除该代码段(如果存在),您需要 migrate MSBuild-Integrated solutions to use Automatic Package Restore