Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuget not downloaded packages under Visual Studio Team Services (visualstudio.com) (Automatic Package Restore)

I am really going nuts here with nuget and building a solution under Visual Studio Team Services (visualstudio.com). Any help will be much appreciated.

I have a solution containing 36 projects. Many projects use the same 5 or 6 nuget packages. I have carefully followed instructions for Migrating MSBuild-Integrated solutions to use Automatic Package Restore and therefore have a .nuget folder under my solution folder which contains a sole NuGet.Config file and no longer contains Nuget.exe or Nuget.targets files. All projects have had their Nuget.targets lines removed.

I am using Visual Studio 2013 Professional (v12 Update 2) and the solution builds locally without errors or warnings. Even after a Clean and deletion of the packages folder it downloads and builds fine. The packages folder is NOT checked into Visual Studio Team Services.

Examining the build log suggests that:

  1. nuget did not kick in at the start of the Build in order to check for, download and unpack any unresolved packages (it was doing this before migrating from MSBuild-Integrated to Automatic Package Restore - however despite that, it wasn't able to resolve references)
  2. I am left with 113 errors, centred around the fact that projects were unable to resolve references.
  3. Unlike a local build (and MSBuild-Integrated), Visual Studio Team Services now doesn't even mention nuget in its build log!!!

An example of the log where things start to fail (although this is obviously because nuget hasn't stepped in):

Project "C:\a\src\TFS\RSPlatform\Main\Source\RSPlatform Team Project.sln" (1) is building "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\A2Refresh.csproj" (8) on node 1 (default targets).
PrepareForBuild:
  Creating directory "obj\Release\".
ResolveAssemblyReferences:
  Primary reference "Bytescout.Spreadsheet".
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Bytescout.Spreadsheet". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\A2Refresh.csproj]
          For SearchPath "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies".
          Considered "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies\Bytescout.Spreadsheet.winmd", but it didn't exist.
          Considered "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies\Bytescout.Spreadsheet.dll", but it didn't exist.
          Considered "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies\Bytescout.Spreadsheet.exe", but it didn't exist.
          For SearchPath "{HintPathFromItem}".
          Considered "..\..\packages\Bytescout.Spreadsheet.2.4.0.1346\lib\net45\Bytescout.Spreadsheet.dll", but it didn't exist.
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Bytescout.Spreadsheet.winmd", but it didn't exist.
          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Bytescout.Spreadsheet.dll", but it didn't exist.
          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Bytescout.Spreadsheet.exe", but it didn't exist.
          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Bytescout.Spreadsheet.winmd", but it didn't exist.
          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Bytescout.Spreadsheet.dll", but it didn't exist.
          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Bytescout.Spreadsheet.exe", but it didn't exist.
          For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.5.1,AssemblyFoldersEx}".
          Considered AssemblyFoldersEx locations.
          For SearchPath "{AssemblyFolders}".

Can anyone advise how I should get Visual Studio Team Services to use nuget? How is Visual Studio Team Services even suposed to use NuGet if Automatic Package Restore suggests dropping ~/.nuget/NuGet.exe?

Thanks in advance, Chris

like image 577
Chris Walsh Avatar asked Jun 12 '14 00:06

Chris Walsh


People also ask

How do I enable NuGet package restore in Visual Studio?

To do that, go to Tools, NuGet Packaged Manager, then go to Package Manager Settings. Go to the General section, and then make sure you have a checkmark for Allow NuGet to download missing packages and also to automatically check for missing packages during the build in Visual Studio. So click on OK.

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

How do I fix a missing NuGet package?

You can restore packages manually with nuget restore , dotnet restore , msbuild -t:restore , or through Visual Studio. The dotnet build and dotnet run commands automatically restore packages, and you can configure Visual Studio to restore packages automatically when it builds a project.


1 Answers

If you are building on Visual Studio Team Services then I have found that both Nuget.exe and Nuget.targets need to be present, which seems to be contrary to all the advice you can find by googling this subject.

Adding them in got my Visual Studio Team Services builds working.

like image 90
IntoNET Avatar answered Oct 07 '22 05:10

IntoNET