TFS Online Build Fails - NuGet Package Repair Not Working

I would like to help you solve this problem. The code is compiled in a local box, but the TFS build fails for the project saying -

Entity \ DbModel.Context.cs (16): The type or namespace name "Entity" does not exist in the namespace "System.Data" (are you missing an assembly reference?)

Entity \ DbModel.Context.cs (19): The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)

Entity \ DbModel.Context.cs (26): The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?)

I am using EntityFramework 6.1.1. NuGet package for project and package restore included (in NuGet.targets file) -

<RestorePackages Condition="  '$(RestorePackages)' == '' ">true</RestorePackages>

      

I think that loading the package for EntityFramework also fails in TFS, even if other NuGet packages for the same project are loaded before starting the build in TFS.

I am using 2 packages for this project -

<packages>
<package id="EntityFramework" version="6.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
</packages>

      

Build log file -

RestorePackages:
  "C:\a\src\.nuget\NuGet.exe" install "C:\a\src\<project name>\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "C:\a\src\ "
  Restoring NuGet packages...
  To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
  Installing 'Newtonsoft.Json 6.0.6'.
  Successfully installed 'Newtonsoft.Json 6.0.6'.
  All packages listed in packages.config are already installed.

      

But after Newtonsoft.Json it didn't even load the EntityFramework DLL.

+3


source to share


1 answer


Finally, I got it working. It took a while. There are currently 2 different options available:

  • Save the NuGet.targets file and write that NuGet.targets file from the whole project (Didnt work for me)

  • Explicitly invoke NuGet.Exe package restore before build

Option 1 didn't work for me, so in order to continue with the second option, I had to do:



  • Delete NuGet.targets file from .nuget folder (don't check this file)

  • Delete and do not check the package file

  • Open all project files in notepad and remove the reference to the NuGet.targets file as mentioned at http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore

  • Go to VS 2013 - Tools> Extensions and Updates> VS Gallery - make sure you have the latest NuGet

  • At this point, your project is ready to download Nuget packages right before any build, to check to remove the packages folder and start building, it should download all NuGet packages.

  • Now for TFS Continuous build, instead of specifying the solution file directly in the build template, use your own XML build.proj as stated at http://blogs.msdn.com/b/dotnet/archive/2013/08/27/nuget-package- restore-with-team-foundation-build.aspx .

  • This XML calls the NuGet.EXE \ .sln restore file first, if no * .sln file is mentioned it picks up any other solution file in the same directory

  • Check build.proj file, NuGet.exe in root folder along with solution file

Now, everything is going smoothly for me with TFS online CI. Don't right click on the Visual Studio solution to enable NuGet package restore - it will override all of the above as it returns the NuGet.targets file and a direct file link in each proj file.

+3


source







All Articles