Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 368
Ev. Avatar asked Oct 19 '15 23:10

Ev.


People also ask

How do I change the source of a NuGet package?

To manage your package sources, select the Settings icon or select Tools > Options. In the Options window, expand the NuGet Package Manager node and select Package Sources. To add a source, select +, edit the Name, enter the URL or path in Source, and then select Update.

Where is NuGet packages config?

By default, all NuGet clients (the command-line tool, the Visual Studio extension and the Package Manager Console) all make use of the default NuGet configuration file which lives under %AppData%\NuGet\NuGet. config. NuGet can make use of other configuration files as well!


1 Answers

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
like image 155
Matt Ward Avatar answered Sep 21 '22 21:09

Matt Ward