aspnet / dnx

OBSOLETE - see readme
Other
963 stars 224 forks source link

KPM-built NuGet on Mono pkg throws NotSupportedException when opening in NuGet.Core's OptimizedZipPackage #649

Closed xavierdecoster closed 9 years ago

xavierdecoster commented 10 years ago

We can provide a package that demonstrates the issue. It was built with KPM using the following command: kpm build

The symptoms were reported to @MyGet on September 19, 2014, by @viniciuschiele. He should be able to answer any questions you might have regarding how the package was built. The package and a solution reproducing the issue have been emailed to @davidfowl and @jeffhandley (and can be sent over again upon simple request).

Symptoms:

NuGet.Core's OptimizedZipPackage class is using System.IO.Packaging.Package.Open(path) (from Windowsbase.dll v4.0.0) internally. It is this call that throws the NotSupportedException with the above message. We used NuGet.Core.2.8.3-alpha0001.

The following piece of code reproduces this internal issue:

var fullPackagePath = Path.GetFullPath("Aero.ConfigHub.1.0.0.0.nupkg");
using (Stream stream = File.OpenRead(fullPackagePath))
{
    Package package = Package.Open(stream); // throws NotSupportedException
}

Diving into the symbols where the exception got thrown, I traced it back to the static ZipArchive.VerifyVersionNeededToExtract method. When parsing the _rels/.rels, the version parameter at some point has a value of 63, which does not have a matching value in the ZIPIOVersionNeededToExtract enum.

debugging

Looks like the packages produced by NuGet are using different implementations of OptimizedZipPackage, ZipArchive and ZipPackage than the ones being used in K. Perhaps there's some incompatibility there, not sure.

viniciuschiele commented 10 years ago

Complementing, I've built this package using KRE 1.0.0-alpha4-10353 and Mono 3.8 on OSX

Below project.json

{
  "version": "1.0.0.0",
  "dependencies": {
    "NLog": "3.1.0"
  },

  "frameworks": {
    "net45": {
      "dependencies": { }
    }
  }
}
davidfowl commented 10 years ago

That makes alot more sense. Can you try a windows machine

viniciuschiele commented 10 years ago

Ok, on Windows it worked well. Just so you know, Xunit also not worked on OSX.

Thanks David!

davidfowl commented 10 years ago

xunit? What?

viniciuschiele commented 10 years ago

When I run my unit tests using Xunit (Xunit.KRunner) it gives me that error:

Missing method Microsoft.Framework.Runtime.IApplicationEnvironment::get_RuntimeFramework() in assembly data-0x7ff52b049000, referenced in assembly /Users/vinicius/.kpm/packages/Xunit.KRunner/1.0.0-alpha4-10314/lib/net45/Xunit.KRunner.dll System.MissingMethodException: Method not found: 'Microsoft.Framework.Runtime.IApplicationEnvironment.get_RuntimeFramework'. at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0

davidfowl commented 10 years ago

Ok that's unrelated and because you're using incompatible versions of the KRE and the xunit package. Let's try to keep this bug focused on the nuget/zip issue

muratg commented 9 years ago

Hi @xavierdecoster do you still have this problem? Thanks.

xavierdecoster commented 9 years ago

@muratg I can verify and run it through a test setup if @viniciuschiele can send us a new package built on Mono using the latest kpm beta

davidfowl commented 9 years ago

This is still a problem, the long term solution is nuget core changing to read zip and produce OPC. /cc @jeffhandley

davidfowl commented 9 years ago

Closing this as by design. The new NuGet 3 API s required to open packages now :smile: