Exception when pushing with nuget.exe

Jan 15, 2012 at 8:47 PM

I've rolled my own nuget feed and implemented enough where it can list and download packages. (This is more for me figuring out the backend of nuget, I'm aware of Nuget.Server, I just want to play with integrating my own storage, etc.) However, I couldn't get pushing to work even following the code from the nuget gallery, so I figured I'd trace the command line and see what it tries to do against the server. So I cloned the hg repo, and try to debug the CommandLine with args: push SomePackage -Source test, where test is my nuget server running on vs dev web server (the service comes up and /Packages shows my packages).

When debugging I cannot get past line 58 of ZipPackage.cs. It is a call to EnsureManifest() but it immediately throws an exception without stepping into the method body:

Inheritance security rules violated while overriding member: 'NuGet.ManifestMetadata.Validate(System.ComponentModel.DataAnnotations.ValidationContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

Command line then quits with red error: The underlying connection was closed: An unexpected error occurred on a receive.

Given that it never even gets to the point where it tries to communicate with the server, I can't help but think there's something else going on. Anyone?

Jan 15, 2012 at 10:13 PM

Yes, that's a weird CLR issue that only happens in the debugger. See this post for more details and a workaround.

Jan 16, 2012 at 1:00 AM

Thanks for that, that solved it. Why wouldn't you wrap that in an #if DEBUG statement (and/or mention it on the 'setting up your environment' doc)?

Jan 16, 2012 at 2:18 AM

Not sure we'd want to take it out altogether in DEBUG, because it generally want debug and retail to run the same way, and this issue doesn't happen at normal runtime (only when debugging). And I think it's only an issue in nuget.exe (might be wrong).

But yes, it should be documented more clearly.