Yoda
Yoda

Reputation: 18068

NuGet omits some packages but restoring them manually project by project through VS2017 is a success

I created a build definition in VSTS for our project. In the NuGet Installer step I specify:

Path to solution or packages.config: DirectoryName/AppServer/.nuget/NuGet.Config
Path to NuGet.config: DirectoryName/AppServer/.nuget/NuGet.Config
Installation type: Restore
NuGet arguments: -PackagesDirectory DirectoryName\SDK\NuGet\packages
NuGet Version: 3.3.0

When I run the build execution, I get info on the console:

2017-07-31T11:39:10.2496191Z ##[section]Starting: NuGet restore DirectoryName/AppServer/AppServer.sln
2017-07-31T11:39:10.2808709Z ==============================================================================
2017-07-31T11:39:10.2808709Z Task         : NuGet Installer
2017-07-31T11:39:10.2808709Z Description  : Installs or restores missing NuGet packages
2017-07-31T11:39:10.2808709Z Version      : 0.2.31
2017-07-31T11:39:10.2808709Z Author       : Microsoft Corporation
2017-07-31T11:39:10.2808709Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)

it restores a lot of packages, but some are not restored. No errors are thrown, no warnings, they are just omitted and that causes the Build solution task to fail.

However, when I log onto virtual machine (Azure) and open the solution in Visual Studio 2017 and click on every project in it one by one and right click on it, then restore NuGet packages, everything is downloaded successfully. Then build definition execution is a success under condition that I set Clean to false in Get sources step.

Upvotes: 0

Views: 86

Answers (2)

starian chen-MSFT
starian chen-MSFT

Reputation: 33728

Try to use NuGet 4.0.0 version (specify it in Advanced section of NuGet Installer task).

On the other hand, there are 1.* and 2.* versions of NuGet task available, you can use the newest version of task.

enter image description here

Upvotes: 1

Imre Pühvel
Imre Pühvel

Reputation: 5004

This caught my attention:

and click on every project in it one by one

This is probably not the same that your VSTS automation is doing, is it?

One possible cause is that one of your projects is referencing a nuget resource from it's packages folder, but the reference is missing from packages.config. If some other project has the package correctly referenced then it happens to magically be available, but only when someone has compiled that project first. If that project is not built then your incorrectly configured project would fail as well.

So I would suggest you to:

  1. Examine build error to determine which package is causing the trouble
  2. Verify given package is indeed correctly set up in packages.config in the failed project and resources are loaded from the correct folder (version matches).

Also, you should verify the logs and build errors not by manually compiling every single project but reproducing the exact steps that your build server is doing. Which usually is to clean and build the entire solution.

Upvotes: 0

Related Questions