NuGet package missing while trying to use TFS Servcice service

I hope someone can help diagnose what is happening with my build. I am using Visual Studio 2012, NuGet 2.7 and the TFS service (git). I could not get around the following error:

"C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj (361): 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=317567." 

I turned on the package restore function (but I think I heard with nuget 2.7, it doesn't matter). Anyway, I found a useful blog about this issue: Blog article

Here is my current build script:

 <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <OutDir>$(MSBuildThisFileDirectory)bin</OutDir> <Configuration>Release</Configuration> <ProjectProperties> OutDir=$(OutDir); Configuration=$(Configuration); </ProjectProperties> </PropertyGroup> <ItemGroup> <Solution Include="$(MSBuildThisFileDirectory)src\*.sln" /> </ItemGroup> <Target Name="RestorePackages"> <Exec Command="&quot;$(MSBuildThisFileDirectory)src\.nuget\NuGet.exe&quot; restore &quot;%(Solution.Identity)&quot;" /> </Target> <Target Name="Clean"> <MSBuild Targets="Clean" Projects="@(Solution)" Properties="$(ProjectProperties)" /> </Target> <Target Name="Build" DependsOnTargets="RestorePackages"> <MSBuild Targets="Build" Projects="@(Solution)" Properties="$(ProjectProperties)" /> </Target> <Target Name="Rebuild" DependsOnTargets="RestorePackages"> <MSBuild Targets="Rebuild" Projects="@(Solution)" Properties="$(ProjectProperties)" /> </Target> </Project> 

and here is my build log:

 Build started 9/27/2013 1:01:14 AM. Project "C:\a\src\build.proj" on node 1 (default targets). RestorePackages: "C:\a\src\src\.nuget\NuGet.exe" restore "C:\a\src\src\RecipeDb.sln" Project "C:\a\src\build.proj" (1) is building "C:\a\src\src\RecipeDb.sln" (2) on node 1 (Build target(s)). ValidateSolutionConfiguration: Building solution configuration "Release|Any CPU". Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (3) on node 1 (default targets). C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj(361,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=317567. Done Building Project "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default targets) -- FAILED. Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (5) on node 1 (default targets). C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,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=317567. Done Building Project "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default targets) -- FAILED. Done Building Project "C:\a\src\src\RecipeDb.sln" (Build target(s)) -- FAILED. Done Building Project "C:\a\src\build.proj" (default targets) -- FAILED. Build FAILED. "C:\a\src\build.proj" (default target) (1) -> "C:\a\src\src\RecipeDb.sln" (Build target) (2) -> "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default target) (3) -> (EnsureBclBuildImported target) -> C:\a\src\src\RecipeDb.M vc\RecipeDb.Mvc.csproj(361,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=317567. "C:\a\src\build.proj" (default target) (1) -> "C:\a\src\src\RecipeDb.sln" (Build target) (2) -> "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default target) (5) -> C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,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=317567. 0 Warning(s) 2 Error(s) Time Elapsed 00:00:09.21 

So, I copied his build log and just changed the path where nuget.exe is. The Nuget.exe command seems to work, but apparently it does not load packages. Of course, creating locally works fine (even if I delete the package directory.

+7
tfs nuget msbuild vsts
source share
2 answers

As I can see in the link in the error message line:

In Nuget 2.7, the following has been improved:

Improvement

We updated Microsoft.Bcl.Build to use a different approach. the new version will use conditional imports, similar to the NuGets auto-import feature . This will always allow the project to load into Visual Studio.

However, Microsoft.Bcl.Build also adds a goal to your project that will be launched after the build is complete. This target checks the current assembly of the restored packages, and if this fails to build using the error message:

Package Restore Error

Recovered NuGet Packages. Build the project again to include these packages in the assembly. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568 .

Building a second time will fix this error. Please note that this error will only appear if packages are missing, so it doesn’t seem like you always have to build twice.

However, it is stated below that he will not consider server building / continuous integration (CI) scenarios, and he needs the solution indicated in the following excerpt from the article:

This solution does not address assembly server / continuous integration (CI). To successfully use package recovery on the build server, you have two options:

  • Go to the .targets file.
  • Explicitly performing NuGet package recovery before creating a project / solution.

Hope the problem you are facing is also due to this.

+4
source share

I need a link to Microsoft.Bcl.Build and BeforeTargets = "BeforeBuild". This was added when Microsoft.Bcl.Build was added as a dependency on the Azure Nuget package. Try to check the project file and delete it.

  <Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" /> <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''"> <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="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=317567." HelpKeyword="BCLBUILD2001" /> <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" /> </Target> 
+1
source share

All Articles