NuGet package rejects nuspec files with files element

Dec 14, 2010 at 3:54 AM

The documents page provides a link to the Nuspec file specification: http://nuget.codeplex.com/documentation?title=Nuspec%20Format.

Based on that page, I thought there was a way to specify the files to be included in a specific package by including a <files> element within the <metadata> element. When I try to include this element, NuGet.exe errors with the following exception:

The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd' has invalid child element 'files' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'. List of possible elements expected:'dependencies, requireLicenseAcceptance, iconUrl, tags, owners' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'.

I have tried building from source (nice build script, btw) and also just downloading the most recent command line app from the site and I see the error in both cases. The last trunk commit's nuspec.xsd (in the NuPack.Core project) shows that the <files> element is valid so at this point I'm very confused.

On a positive note, I really like the idea of a package manager for .Net and appreciate all the hard work and effort put into this. I'd love to be able to add my open source projects to NuGet and look forward to working through this issue.

Thanks!

Alex Robson

Dec 14, 2010 at 4:00 AM

That's a mistake in the documentation. Try putting the <files> section outside <metadata> (as a sibling of it).

Coordinator
Dec 14, 2010 at 4:53 AM

No, the docs are correct when it comes to the files element. It doesn't state that they belong in the metadata section but mentions them as one of the top level elements. I tried updating the documentation to be more clear about this to avoid confusion in the future.

Dec 14, 2010 at 6:14 AM

Thanks guys.

@haacked - the misleading bit is actually the top table because it is titled Metadata elements and files is included in that list (or it was, maybe you fixed it already ;). If I had read further and not just dove in I would've come across the clarification further down the page. Not trying to be nit-picky, but I would suggest either renaming that first table or moving the files element out of it for the over-eager folks such as myself : )

Really great having this kind of support. Great project, great community.

Thanks!

Alex

Coordinator
Dec 14, 2010 at 5:22 PM

That *is* misleading. I’ve corrected it. Thanks!

Dec 14, 2010 at 8:18 PM

I am seeing this similar error since upgrading nuget this morning:

The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd' has invalid child element 'created' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'. List of possible elements expected:'dependencies, requireLicenseAcceptance, iconUrl, tags, owners' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'. 

I was orginally seeing this when selecting "Add Library Package  Refernece..." then based on the discussion at http://nuget.codeplex.com/Thread/View.aspx?ThreadId=237992 I figured out it was my prior install of elmah.

 

I commented out the line "<package id="elmah" version="1.1" />" in the packages.config file in the mvc app I am having problems with this morning.
Now the Package Manager UI is loading but I still see this error when trying to reinstall elmah.

Kevin Priester

Dec 14, 2010 at 9:40 PM

Kevin, do you see this in a new project as well, or only the existing one?  Can you check the feed URL that you're configured to use?

Dec 15, 2010 at 12:28 PM

Looks like just exsiting ones. I succsfully added elmah to a new project.

http://go.microsoft.com/fwlink/?LinkID=206669

Dec 15, 2010 at 7:15 PM

And do you remember how long ago you had installed those packages in your existing solution?  The packages have gone through various changes through time.  In theory, the packages from just before we moved to the latest build should be compatible

Dec 15, 2010 at 7:58 PM

I added it on 11/08/2010 at 8:16 am EST.

Dec 15, 2010 at 8:23 PM

Just noticed in the error that it's complaining about the 'created' tag, which is something we supported in the CTP1 feed but not CTP2.  Anyway, we should not see this issue going forward.  After 1.0 is official, we will avoid breaking changes, so these are just early adoption pains :)

Dec 16, 2010 at 12:49 AM

Sounds great. How do I back out the installed package so that I can use NeGet on this existing app?

My existing app with nuget/package already installed is in an odd state with this error popping up.

 

Dec 16, 2010 at 6:25 AM

Try deleting the packages folder (sibling to the solution file), and the packages.config file in the project root (one per project if you have multiple).

Dec 16, 2010 at 2:01 PM

That worked.

Just an FYI, when I re-added the packages to make sure my solution in version control had all the right bits, I found that I now had redundant config sections in my web.config.

Not sure if this would be a problem in the future, but you may want to look into the redundant config entries. 

 

Dec 16, 2010 at 7:51 PM

Hmmm, that's strange, I would not have expected duplication.  We'll investigate.

Dec 16, 2010 at 7:57 PM

I filed bug http://nuget.codeplex.com/workitem/478 to track this.

Dec 18, 2010 at 7:33 PM

I was having the same issue with NuGet not functioning due to the 'created' tag.  The only package I had in my project was elmah, so I went into the web.config and removed all references to elmah, then removed the packages.config and the packages directory.  That combination seems to have fixed everything.  Glad I found this discussion.

Dec 21, 2010 at 9:21 PM
dbatten wrote:

I was having the same issue with NuGet not functioning due to the 'created' tag.  The only package I had in my project was elmah, so I went into the web.config and removed all references to elmah, then removed the packages.config and the packages directory.  That combination seems to have fixed everything.  Glad I found this discussion.

 

I had the same issue.  I had a previous version installed, so I simply removed the /packages folder and it fixed the problem.