Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Xml.XmlException: Unrecognized root element in Core Properties part. Line 2, position 2. #2718

Closed
ghost opened this issue May 4, 2016 · 12 comments

Comments

@ghost
Copy link

ghost commented May 4, 2016

One of my projects is failing to pack with the following errors which seems related to:

This has happened after a merge from a different source branch (which still seems to compile and pack properly) However, only a small amount of code has changed with some packages changes in packages.config.

I was running nuget.exe v.3.3 but after reading ##1921 and updating to a new version (NuGet Version: 3.4.3.855:) I am still getting the following error

I cant see any issues with the nuspec file, or the packages.config

NuGet Pack ./Ucas.UnitTests.Common/Ucas.UnitTests.Common.csproj -IncludeReferencedProjects -Verbosity detailed -MSBuildVersion 14 -Build

The build works but the zipping of the files is failing with the following stack trace:

C:\Development\BitBucket\WIP\Identity>NuGet Pack ./Ucas.UnitTests.Common/Ucas.UnitTests.Common.cspro
j -IncludeReferencedProjects -Verbosity detailed -MSBuildVersion 14 -Build
Attempting to build package from 'Ucas.UnitTests.Common.csproj'.
Building project 'C:\Development\BitBucket\WIP\Identity\Ucas.UnitTests.Common\Ucas.UnitTests.Common.
csproj' for target framework '.NETFramework,Version=v4.6'.
Packing files from 'C:\Development\BitBucket\WIP\Identity\Ucas.UnitTests.Common\bin\Debug'.
Using 'Ucas.UnitTests.Common.nuspec' for metadata.
Add file 'C:\Development\BitBucket\WIP\Identity\Ucas.UnitTests.Common\bin\Debug\Ucas.UnitTests.Commo
n.dll' to package as 'lib\net46\Ucas.UnitTests.Common.dll'
Add file 'C:\Development\BitBucket\WIP\Identity\Ucas.UnitTests.Common\bin\Debug\Ucas.UnitTests.Commo
n.xml' to package as 'lib\net46\Ucas.UnitTests.Common.xml'
System.Xml.XmlException: Unrecognized root element in Core Properties part. Line 2, position 2.
at MS.Internal.IO.Packaging.PartBasedPackageProperties.ParseCorePropertyPart(PackagePart part)
at MS.Internal.IO.Packaging.PartBasedPackageProperties.ReadPropertyValuesFromPackage()
at MS.Internal.IO.Packaging.PartBasedPackageProperties..ctor(Package package)
at System.IO.Packaging.Package.get_PackageProperties()
at NuGet.OptimizedZipPackage.<>c__DisplayClassa.b__9(PackagePart part)
at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at NuGet.OptimizedZipPackage.EnsurePackageFiles() at NuGet.OptimizedZipPackage.GetFilesBase() at NuGet.LocalPackage.GetFiles() at NuGet.PackageExtensions.GetFiles(IPackage package, String directory) at NuGet.CommandLine.ProjectFactory.<>c.<AddFiles>b__92_2(IPackage a) at System.Linq.Enumerable.<SelectManyIterator>d__162.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at NuGet.CommandLine.ProjectFactory.AddFiles(PackageBuilder builder, String itemType, String targ etFolder) at NuGet.CommandLine.ProjectFactory.<>c__DisplayClass56_0.<CreateBuilder>b__1(ProjectFactory p) at NuGet.CommandLine.ProjectFactory.RecursivelyApply(Action1 action, Object alreadyAppliedProjec
ts)
at NuGet.CommandLine.ProjectFactory.RecursivelyApply(Action1 action) at NuGet.CommandLine.ProjectFactory.ApplyAction(Action1 action)
at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath)
at NuGet.CommandLine.PackCommand.BuildFromProjectFile(String path)
at NuGet.CommandLine.PackCommand.BuildPackage(String path)
at NuGet.CommandLine.PackCommand.ExecuteCommand()
at NuGet.CommandLine.Command.ExecuteCommandAsync()
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

@ghost
Copy link
Author

ghost commented May 4, 2016

as an addendum to this.
When run in Package manage Console (VS2015)
I had thought this might be an issues with XML documentation files embedded - but having removed those and rebuilt the solution, I still get the same error.

NuGet Pack ./Ucas.UnitTests.Common/Ucas.UnitTests.Common.csproj -IncludeReferencedProjects -Verbosity detailed -MSBuildVersion 14 -Build

Attempting to build package from 'Ucas.UnitTests.Common.csproj'.
Building project 'C:\Development\BitBucket\WIP\Identity\Ucas.UnitTests.Common\Ucas.UnitTests.Common.csproj' for target framework '.NETFramework,Versi
on=v4.6'.
Packing files from 'C:\Development\BitBucket\WIP\Identity\Ucas.UnitTests.Common\bin\Debug'.
Using 'Ucas.UnitTests.Common.nuspec' for metadata.
Add file 'C:\Development\BitBucket\WIP\Identity\Ucas.UnitTests.Common\bin\Debug\Ucas.UnitTests.Common.dll' to package as 'lib\net46\Ucas.UnitTests.Co
mmon.dll'
NuGet.exe : System.Xml.XmlException: Unrecognized root element in Core Properties part. Line 2, position 2.At line:1 char:1

  • NuGet Pack ./Ucas.UnitTests.Common/Ucas.UnitTests.Common.csproj -IncludeReferenc ...

    • CategoryInfo : NotSpecified: (System.Xml.XmlE... 2, position 2.:String) [], RemoteException
    • FullyQualifiedErrorId : NativeCommandError

    at MS.Internal.IO.Packaging.PartBasedPackageProperties.ParseCorePropertyPart(PackagePart part)
    at MS.Internal.IO.Packaging.PartBasedPackageProperties.Re
    adPropertyValuesFromPackage()
    at MS.Internal.IO.Packaging.PartBasedPackageProperties..ctor(Package package)
    at System.IO.Packaging.Package.get_PackageProperties()
    at NuGet.OptimizedZipPackage.<>c__DisplayClassa.b__9(PackagePart part)
    at System.Linq.Enumerable.WhereEnumerableIterator'1.MoveNext()
    at NuGet.OptimizedZipPackage.EnsurePackageFiles()
    at NuGet.OptimizedZipPackage.GetFilesBase()
    at NuGet.LocalPackage.GetFiles()
    at NuGet.PackageExtensions.GetFiles(IPackage package, String directory)
    at NuGet.CommandLine.ProjectFactory.<>c.b__92_2(IPackage a)
    at System.Linq.Enumerable.d__16'2.MoveNext()
    at System.Collections.Generic.List'1..ctor(IEnumerable'1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable'1 source)
    at NuGet.CommandLine.ProjectFactory.AddFiles(PackageBuilder builder, String itemType, String targetFolder)
    at NuGet.CommandLine.ProjectFactory.<>c__DisplayClass56_0.b__1(ProjectFactory p)
    at NuGet.CommandLine.ProjectFactory.RecursivelyApply(Action'1 action, Object alreadyAppliedProjects)
    at NuGet.CommandLine.ProjectFactory.RecursivelyApply(Action'1 action)
    at NuGet.CommandLine.ProjectFactory.ApplyAction(Action'1 action)
    at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath)
    at NuGet.CommandLine.PackCommand.BuildFromProjectFile(String path)
    at NuGet.CommandLine.PackCommand.BuildPackage(String path)
    at NuGet.CommandLine.PackCommand.ExecuteCommand()
    at NuGet.CommandLine.Command.ExecuteCommandAsync()
    at NuGet.CommandLine.Command.Execute()
    at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

@ghost ghost closed this as completed May 4, 2016
@ghost
Copy link
Author

ghost commented May 4, 2016

Accidentally closed in error!

@ghost ghost reopened this May 4, 2016
@rrelyea rrelyea added this to the 3.5 RC milestone May 4, 2016
@toddm
Copy link

toddm commented May 5, 2016

This sounds like it might be the same issue as #2651 that is fixed in 3.4.4. Would you verify that our upcoming release fixes the problem?

@ghost
Copy link
Author

ghost commented May 6, 2016

No luck with the new version same error reported

However: I managed to work out a way to reproduce this error consistently after messing around with my project, finally pinning it down to a single a single library: structureMap.automocking.

As soon as following line is added the error occurs
<package id="Structuremap.Automocking" version="4.0.0.315" targetFramework="net461" />

So:

  1. I created a console app
  2. added a Console.WriteLine("Helllo World");
  3. Built and ran " nuget pack" with a default spec file.
    It worked, "pack"ing with old and new versions of nuget.exe
  4. Add a NuGet reference to structuremap.automocking (version is irrelevant)
    This brings in structuremap and RhinoMocks as dependencies.
    Build and run: Works
  5. NuGet pack fails with error.

It's worth noting that this is with any version on the library, not just the most recent and is independent of the libraries dependencies.
- If I remove the dependencies from the package, but not automock ref; it fails
- Only when that specific line from packages.config is removed does the pack command work.

I can't see anything wrong with the downloaded packages, nor can I find another library to replicate this issue.

Hope this helps; my problem is that this issue is a blocker to me: This library is added as an imported dependency.

I'll play around and add to this if I can find anything else.....

@toddm
Copy link

toddm commented May 6, 2016

Thanks. It's always nice to get an exact way to reproduce the problem. I created a project, added structuremap.automocking, and then pack shows the error. I'll start debugging it to see if I can fix it.

@ghost
Copy link
Author

ghost commented May 6, 2016

Have actually tried to debug ... but realised it's DNX now which I'm not conversant with. Bit of an intuitive leap!

@toddm
Copy link

toddm commented May 6, 2016

It appears to be the .NET packaging that throws the XML exception when reading the properties of the zip file. Still trying to work out the root cause, though. The packages might be bad but I don't know for sure yet.
I did find one workaround that could possibly help if you don't need particular versions. If I use v2.6.4.1 of structuremap.automocking, that package works fine. It depends on structuremap, though, that has the issue, but if I take a new version of that (v4.2.0.402), I can pack up my test project.
I'll keep on working on trying to fix it.

@toddm
Copy link

toddm commented May 6, 2016

The structuremap.automocking package was created by using paket.exe instead of NuGet.exe. The standard .NET zip package code is throwing the XML exception trying to read the package properties. There doesn't seem to be a NuGet bug here. It seems to be that the packages are bad.
I'd suggest you contact the package owner and suggest they pack using NuGet.exe instead.

@ghost
Copy link
Author

ghost commented May 6, 2016

Thanks for your investigation. I'll raise it with author. I'll also raise it with the creators of paket.exe

You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHubhttps://github.com//issues/2718#issuecomment-217515915

@forki
Copy link

forki commented May 9, 2016

@toddm can you please explain what exactly is wrong? The package looks right in Nuget package explorer and also installs fine.

@forki
Copy link

forki commented May 9, 2016

This is the coreProp.psmdcp file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <dc:creator>[Jeremy Miller]</dc:creator>
  <dc:description>StructureMap AutoMocker for RhinoMocks</dc:description>
  <dc:identifier>structuremap.automocking</dc:identifier>
  <version>Some(4.0.0.315)</version>
  <keywords />
  <dc:title>structuremap.automocking</dc:title>
  <lastModifiedBy>paket</lastModifiedBy>
</Relationships>

looking into other packages I see "coreProperties" instead of "Relationships" nodes.

That looks indeed strange. I assume it's built with older paket.exe

@toddm
Copy link

toddm commented May 9, 2016

I'm not sure what is causing the error, but here is a way to test it. I created a blank console app and tried this:
using System.IO.Packaging;

        using (Stream stream = new FileStream(@"C:\<path>\structuremap.automocking.4.0.0.315.nupkg", FileMode.Open))
        {
            Package package = Package.Open(stream);
            var properties = package.PackageProperties;
        }

It throws the exception when reading the PackageProperties. Some of the earlier versions of the nupkg don't throw.

@toddm toddm closed this as completed May 16, 2016
@rrelyea rrelyea modified the milestones: Future-1, 4.0 RC Oct 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants