11
votes

I am getting these errors when running a MSBuild build step that builds a web project in TeamCity and I have setup my Nuget targets file PackageSource to point to a local Nuget server e.g. PackageSource Include="http://mylocaldevurl/nuget/Packages" .

The build runs and produces errors of the form e.g. Exec] F:\TeamCity\buildAgent\work\blahblah.nuget\NuGet.targets(87, 9): Unable to read package from path 'Lucene.Net.3.0.3.nupkg'.

Whats is strange other packages are downloaded fine to the TeamCity working folder -the package folder.

The local Nuget Server contains copies of my VS solution packages(the ones in the default packages folder) with only the .nupkg files.

My question is there something that I need to do when copying the .nupkg files to that server.I might be missing something.

I have already doubled checked that the packages exist in the local Server

6

6 Answers

15
votes

I had this same problem using TFS. What I did that fixed it was clear the nuget cache in the user profile that was running the build (%LocalAppData%\NuGet\Cache). I just emptied the directory and ran the build again, then it worked.

6
votes

If your TeamCity is running under System user account then you can try to clear Nuget Cache which is located in one of these folders:

  • C:\Windows\System32\config\systemprofile\AppData\Local
  • C:\Windows\SysWOW64\config\systemprofile\AppData\Local
4
votes

In my case, the service account being used to run the build agent had restricted access out to the Internet through our WebSense proxy.

The error message I was getting in the build log:

Unable to read package from path 'EntityFramework.5.0.0.nupkg'.

I navigated to the cache folder for the build agent user (C:\Users\{BuildAgentUser}\AppData\Local\NuGet\Cache) and found the .nupkg file there that was causing the error.

I could see that something was wrong, as the file was only 3KB, when on my own machine it was over 1MB.

Looking at the contents of the .nupkg file revealed the problem - the download had been blocked by WebSense and it actually contained the error message that would have been displayed had it been browsed to in a web browser.

0
votes

We do this by updating the NuGet config file for the user that the BuildAgent is running under instead of setting a package source and it's worked fine since NuGet v1.6.

File: c\Users\svc_teamcity\AppData\Roaming\NuGet\NuGet.config

Looks like:

<activePackageSource>
  <add key="NuGet official package source" value="https://nuget.org/api/v2/" />
  <add key="MyNuGetGallery" value="D:\NuGet.Packages" />
</activePackageSource>
0
votes

I had the same problem, but on a mac. What I did was just delete the one nuget package that was causing the problem. It was located at:

/Users/yourusername/.local/share/NuGet/Cache
0
votes

I know this is an old question, I had faced this issue recently and none of the solution provided above didn't solve my issue. And the reason for the error was, one of the package was corrupted and the .nupkg file size was 0 kb. What I did is the preceding steps, and that solved my issue and I was able to re-install the packages.

  1. Go to your project directory
  2. Open the folder packages
  3. Find the package on which you are getting error (blah.nupkg)
  4. Delete the folder
  5. Build your project and your project will be build successfully