Carsten
Carsten

Reputation: 11636

Why is NuGet unable to restore one single package during TeamBuild, while it works locally?

We are using a custom package repository for our enterprise packages. One of our projects is an ASP.NET MVC project that also uses the official package repository for referencing packages like Entity Framework.

Recently a new package has been uploaded to the official package repository, that accidentally had the same ID as one of ours. We did not really recognized this, because the package did not change and there was no need to update it.

Recently, we started using Team Foundation Server and I created a new build definition for this project. I managed it to get NuGet package restore working with team build but I also realized that the package restore downloaded the wrong package from the official package source. So I renamed our package by adding a prefix to it. Also I uninstalled the old and "wrong" package from the solution and installed the new one (which I checked, does not conflict with an existing package).

Whilst the team build can restore all packages, it allways fails to restore this newly created package.1 Building the solution locally works fine and all packages are restored correctly. The team build fails with the following error message (for each project that references the package):

"...\Main.nuget\NuGet.targets" (89): "Unable to find version '1.0.1.0' of package 'Foo.Bar'." "...\Main.nuget\NuGet.targets" (89): "The command ""...\Main.nuget\NuGet.exe" install "...\Main\Project\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "...\Main\ " " ended with Code 1."

I tried to run the command manually on the build server and it worked without any problems. Only when invoked from team build this command fails. As I said, there is only the package I renamed (say: I removed the old one from the repository, renamed it and uploaded the new one) causing this error.

What can I do to solve this problem?

1UPDATE: I tried to release a new version of the package that could not be restored and updated it within the solution. During this update another package also got updated. It turns out that only those packages which I updated could not be restored.

Upvotes: 3

Views: 346

Answers (1)

Carsten
Carsten

Reputation: 11636

I finally figured out that changing the build user fixes the problem. I used the default setting ("NT-AUTHORITY\NetworkService") previously. I created a local user ("TFS Build") and configured him as user for the build service. Also I granted this user administrator privileges (for first). Building now works and this fixes my problem for first.

However the actual reason for the problem, especially why some packages actually could be restored, remains confusing for me. So if anybody has some additional information for me, I would be very thankful! :)

Upvotes: 3

Related Questions