Reputation: 83
Title pretty much says it all. I have a project which uses some nuget packages. All are downloaded but two of them (HTMLAgilityPack and Newtonsoft) are never installed i.e. the .nupkg file is not extracted, thus, the required .dlls cannot be found and the build fails. Here's the part of the build log file showing when the packages are restored on the build server:
Target "RestorePackages: (TargetId:587)" in file "##\nuget.targets" from project "##.csproj" (target "ResolveReferences" depends on it):
Task "Exec" skipped, due to false condition;
Task "Exec" (TaskId:360) Task Parameter:Command="##\nuget.exe" install "##\packages.config" -source "https://nuget.org/api/v2/" -RequireConsent -solutionDir "##\Sources\" (TaskId:360) Task Parameter:LogStandardErrorAsError=True (TaskId:360) "##\nuget.exe" install "##\packages.config" -source "https://nuget.org/api/v2/" -RequireConsent -solutionDir "##\Sources\ " (TaskId:360)
Successfully installed '###.Utilities.Excel 1.0.0.0'. (TaskId:360) Successfully installed '###.Utilities.FileIO 1.0.0.1'. (TaskId:360) Successfully installed '###.Utilities.String 1.0.0.0'. (TaskId:360) All packages listed in packages.config are already installed.
(TaskId:360) Done executing task "Exec". (TaskId:360) Done building target "RestorePackages" in project "##.csproj".: (TargetId:587)
As you can see, HTMLAgilityPack and Newtonsoft are not installed as part of the RestorePackages task. Why would TFS build download but not install these packages?
Upvotes: 0
Views: 393
Reputation: 27842
As you wrote, an old nuget.exe will do this.
What I do is take the "..nuget\nuget.exe" out of the equation.
I put nuget.exe on the build server.
I store them like this:
C:\MyProgFiles\NuGet\2.8.6\nuget.exe
C:\MyProgFiles\NuGet\3.3.0\nuget.exe
You might ask why I keep the olders. There are occasionally issues with the newest build.
Then on my builds, I setup the build server, I essentially run this:
"C:\MyProgFiles\NuGet\3.3.0\nuget.exe" restore c:\builds\1\SomeDirectory\MySolution.sln -NoCache
Obviously, you'll use macros instead of hard coded paths.
This will (obviously) restore the packages.
I use "NoCache" because occasionally our private nuget cache has things removed......which are cached on the build server. The nocache arg will find this issue sooner than later.
Upvotes: 1
Reputation: 83
If anyone else comes across this it could be that the nuget.exe you're using to restore the packages is outdated. In my case the project I was working on was started by someone else 2 years ago, I added a relatively new nuget package and the old nuget.exe wasn't compatible with it. You can download the latest version of the nuget.exe here .
Upvotes: 0