NuGet.exe Validates Against Old NuSpec Schema

Oct 18, 2011 at 4:36 PM
Edited Oct 18, 2011 at 8:01 PM

Hi,

It looks like the NuGet.exe program available from CodePlex has not been updated for the latest release.  I did execute it on the command-line without any parameters to download the latest version.  But still, I'm getting a schema validation error when building a package from a nuspec file that uses the new references element.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 
System.InvalidOperationException: The element 'metadata' in namespace
'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd' has invalid child element 'references' in namespace
'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'. List of possible elements expected: 'dependencies,
frameworkAssemblies, title, language, summary' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'. at NuGet.Manifest.b__c(Object sender, ValidationEventArgs e) at System.Xml.Schema.XNodeValidator.ValidationCallback(Object sender, ValidationEventArgs e) at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(ValidationEventHandler eventHandler, Object sender,
XmlSchemaValidationException e, XmlSeverityType severity) at System.Xml.Schema.XmlSchemaValidator.ElementValidationError(XmlQualifiedName name, ValidationState context,
ValidationEventHandler eventHandler, Object sender, String sourceUri, Int32 lineNo, Int32 linePos, XmlSchemaSet schemaSet) at System.Xml.Schema.XmlSchemaValidator.ValidateElementContext(XmlQualifiedName elementName, Boolean& invalidElementInContext) at System.Xml.Schema.XmlSchemaValidator.ValidateElement(String localName, String namespaceUri, XmlSchemaInfo schemaInfo,
String xsiType, String xsiNil, String xsiSchemaLocation, String xsiNoNamespaceSchemaLocation) at System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) at System.Xml.Schema.XNodeValidator.ValidateNodes(XElement e) at System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) at System.Xml.Schema.XNodeValidator.ValidateNodes(XElement e) at System.Xml.Schema.XNodeValidator.ValidateElement(XElement e) at System.Xml.Schema.XNodeValidator.Validate(XObject source, XmlSchemaObject partialValidationType, Boolean addSchemaInfo) at System.Xml.Schema.Extensions.Validate(XDocument source, XmlSchemaSet schemas,
ValidationEventHandler validationEventHandler, Boolean addSchemaInfo) at NuGet.Manifest.ValidateManifestSchema(XDocument document) at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider) at NuGet.Commands.ProjectFactory.ProcessNuspec(PackageBuilder builder)

My .nuspec file:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
	<metadata>
		<id>$id$</id>
		<version>$version$</version>
		<authors>$author$</authors>
		<owners>$author$</owners>
		<licenseUrl>http://rxx.codeplex.com/license</licenseUrl>
		<projectUrl>http://rxx.codeplex.com</projectUrl>
		<iconUrl>http://download.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=rxx&amp;DownloadId=243622</iconUrl>
		<requireLicenseAcceptance>false</requireLicenseAcceptance>
		<description>$description$</description>
		<tags>Rx Reactive Extensions Observable .NET LINQ Events</tags>
		<references>
			<reference file="Rxx.dll" />
		</references>
	</metadata>
</package>

Where can I get the most up-to-date version of NuGet.exe for command-line builds?

Thanks,
Dave

Developer
Oct 18, 2011 at 5:20 PM

Just run nuget.exe up -self. The NuGet.exe on codeplex is a bootstrapper that downloads the latest nuget.exe on first run.

Also, remove the schema from your nuget package, we'll pick the best schema based on what you use.

Oct 18, 2011 at 7:59 PM
Edited Oct 18, 2011 at 8:02 PM

Hi,

Thanks for the reply.  Unfortunately, it looks like I'm already running the latest version.  nuget.exe up -self outputs the following message:

Checking for updates from https://go.microsoft.com/fwlink/?LinkID=206669.
Currently running NuGet.exe 1.5.21005.9019.
NuGet.exe is up to date.

And the exe's modified date didn't change.  I'm also still getting the same error when building.

As I mentioned, I ran NuGet.exe without parameters before posting and it appeared to update to the latest version.  It actually created a NuGet.exe.old file, which I deleted and used the new file instead.

> Also, remove the schema from your nuget package, we'll pick the best schema based on what you use.

Well I'm not doing anything with the schema explicitly.  I even searched my entire solution directory (deep) for nuspec.xsd and it doesn't exist, not even in any of the reference packages that I'm using.

However, I should mention that I'm not running NuGet's MSBuild task directly.  I've written a custom MSBuild script that uses NuGet.exe's APis to build a package from my .csproj file.

Perhaps the latest version has changed the way automatic schema detection works or my custom code is circumventing it somehow.  Any ideas?

Thanks,
Dave

Developer
Oct 18, 2011 at 8:04 PM

See this line:

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">

Change it to this:

<package>

Oct 18, 2011 at 8:53 PM

Hi,

Thanks, I understand now.  :)

But that didn't work either - I'm still getting the same error.  Any more ideas?

- Dave

Oct 18, 2011 at 9:17 PM

Hi,

The build script was using an older copy of NuGet.exe from the DevEnv folder, which is required to workaround an in-line task bug in MSBuild.  However, after updating that copy of the .exe as well, the build is still failing with the same error.

I'm going to try a clean build environment now.  I'll get back to you :)

- Dave

Oct 18, 2011 at 10:02 PM
Edited Oct 18, 2011 at 10:03 PM

Hi,

Just had to restart Visual Studio because it cached a copy of the old NuGet.exe in memory.

All is well now, thanks for your help.

- Dave