Ev.
Ev.

Reputation: 7589

How to specify Nuget schema?

I have two projects in the same solution that I use to create nuget packages. When I take each of those packages and unzip it to find the generated nuspec, I find they are each targetting different xml schemas.

Package A:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">

Package B:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">

This is a problem because my build server wants to nuget push them with nuget version 1.7 (and I can't upgrade it) so will only push package A.

How can I force package B to target the same schema as A?

Additional info: Package A targets .Net 4.0 Package B targets .Net 3.5 I'm packing with nuget 2.8 locally and can confirm that the same command generates a different schema version:

nuget pack xxx.csproj -IncludeReferencedProjects -OutputDirectory c:\nuget\MyPackageLibrary -verbosity detailed

(I have a corresponding xxx.nuspec file that gets used for meta data)

I've tried specifying no schema in either .nuspec file

<?xml version="1.0"?>
<package>
<metadata>

and I've tried specifying:

<?xml version="1.0"?> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <metadata>

But it has no effect on the .nuspec I find when I unzip the packaged artifact.

Upvotes: 6

Views: 3690

Answers (1)

Matt Ward
Matt Ward

Reputation: 47917

If you cannot upgrade the build server's version of NuGet then I would just use the same version so the same schema version is generated in the NuGet package.

Looking at the NuGet source code the version of the schema used depends on the feature set used by the NuGet package. For example, if your NuGet package uses an XDT transform then it will use schema version 4 namespace:

http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd

This version 4 namespace is not included in NuGet 1.7. XDT transforms were included in NuGet 2.6.

In NuGet 2.8.7 there are two locations where the schema version is determined.

  • PackageBuilder
  • ManifestSchemaUtility

    • Schema version 4: Dependency contents and tools with target framework defined
    • Schema version 4: Dependencies with target framework defined.
    • Schema version 5: Assembly references with target framework defined
    • Schema version 6: XDT transforms

Upvotes: 5

Related Questions