question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NuGet.Server error "File contains corrupted data" on PUT package on remote server only

See original GitHub issue

Hi!

NuGet.Server (method PackageService.CreatePackage) throws error “File contains corrupted data” on PUT package on remote server only, in IIS hosted application (created by instruction http://nugetserver.net/), but locally all works correctly. It reproducing for any package. Server: Windows Server 2008 R2, .NET 4.5, IIS 7.5, configured application pool with .NET Framework v4.0.30319, managed pipeline mode Integrated. NuGet.Server v2.11.1.0, nuget.exe version 3.4.3.855. Exception:

System.IO.FileFormatException: File contains corrupted data.
at MS.Internal.IO.Zip.ZipIOEndOfCentralDirectoryBlock.FindPosition(Stream archiveStream)
at MS.Internal.IO.Zip.ZipIOBlockManager.LoadEndOfCentralDirectoryBlock()
at MS.Internal.IO.Zip.ZipArchive.OpenOnStream(Stream stream, FileMode mode, FileAccess access, Boolean streaming)
at System.IO.Packaging.ZipPackage..ctor(Stream s, FileMode mode, FileAccess access, Boolean streaming)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
at System.IO.Packaging.Package.Open(Stream stream)
at NuGet.OptimizedZipPackage.EnsureManifest()
at NuGet.Server.Publishing.PackageService.CreatePackage(HttpContextBase context)
at NuGetServer.NuGetRoutes.PushPackage(RequestContext context)

Research shown that problem can be with content type “multipart/form-data”, but we cannot recognize - problem in server, or in RouteMagic+NuGet.Server, or in both. On local machine/devIIS in debug HttpContext.Request.Files has 1 file with package, therefore CreatePackage works as expected. On server HttpContext.Request.Files are empty, but InputStream contains all neccessary headers + data. Requests headers/data on local and server - identical:

PUT /api/package/ HTTP/1.1
Connection: Keep-Alive
Content-Length: 128432
Content-Type: multipart/form-data; boundary="ec6ee113-c37c-4fdc-8f02-2ab7fd2de007"
Accept-Encoding: gzip, deflate
Expect: 100-continue
Host: test.com
User-Agent: NuGet Command Line/3.4.3.855 (Microsoft Windows NT 6.1.7601 Service Pack 1)
X-NuGet-ApiKey: test

--ec6ee113-c37c-4fdc-8f02-2ab7fd2de007
Content-Type: application/octet-stream
Content-Disposition: form-data; name=package; filename=package.nupkg; filename*=utf-8''package.nupkg

PK    „yєHqFу§ ... ZIP package... [Content_Types].xmlPK     „yєH–Э­ѓб  н  Q             =п package/services/metadata/core-properties/e4bb51182ca14486b1a306374401d6fb.psmdcpPK    
 )  Ќс   
--ec6ee113-c37c-4fdc-8f02-2ab7fd2de007--

Were suspected case described here http://forums.iis.net/t/1229356.aspx?Windows+Update+breaks+multipart+form+data, but update KB3104002 are not installed on the server. We will be very grateful if you help to understand because of what it is a problem. Perhaps the reason only properly configured server, but we already no have any ideas. Thank you in advance!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
maartenbacommented, Jun 7, 2016

Thanks all for your help!

Seems NuGet 3.3 and higher touches a server-side feature that is only available in .NET 4.6. Please upgrade your server .NET framework to use .NET 4.6 or higher.

We will be fixing this in the NuGet.Server package as well - https://github.com/NuGet/NuGetGallery/issues/3063

1reaction
stpatrick2016commented, Jun 1, 2016

.NET is 4.6.1. I have uploaded the fiddler logs and sent through support, maybe they will help.

Will try tomorrow or today later to alter the web.config and report results. One thing I already have is the <remove name='WebDAV'/> to fix the issue when push returned 405 (Method not allowed).

Read more comments on GitHub >

github_iconTop Results From Across the Web

File contains corrupted data - Package Manager Console
An easy way to tell if this is your issue, is to run the suspect nuget.exe with a right-click, run as administrator and...
Read more >
Troubleshooting NuGet Package Restore in Visual Studio
Use NuGet Package Restore to download them. The missing file is {name}. This error occurs when you attempt to build a project that...
Read more >
Issues uploading portable library packages [Fixed]
Packages created or published with NuGet Package Explorer, whose decoded folder names had spaces in them, would get ignored as invalid ...
Read more >
Unable to install package 'Microsoft.VisualStudio.NuGet. ...
Unable to install package 'Microsoft.VisualStudio.NuGet.Core,version=15.0.40200.2457', Return code: -2146233033 File contains corrupted ...
Read more >
Visual Studio Preview NuGet Error in Community Forums
Select the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found