I have defined and created a content-only package to share JSON schemas between different projects. I packaged it using nuget.exe
, and could successfully add it to .Net Framework 4.6 library project.
But when I tried to add it to the DotNet Core 3.1 library project (NUnit tests) the following error occurred:
NU1212 Invalid project-package combination for <package name>. DotnetToolReference project style can only contain references of the DotnetTool type
Nuget support documentation (package type, content files) does not list any restrictions (beyond "assuming they are compatible") on the content-only packages. Question is how do I create DotNet Core 3.1 library compatible content-only Nuget package?
I tried disabling all data sources except the local one as suggested in this question, but that didn't make any difference.
Here is a .nuspec
file content
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Package.JsonSchemas</id>
<version>0.0.1</version>
<packageTypes>
<packageType name="Dependency" />
</packageTypes>
<authors>me</authors>
<owners>me</owners>
<releaseNotes>Fill in later</releaseNotes>
<description>Set of JSON schemas.</description>
<tags>json, json-schema, tdv</tags>
<contentFiles>
<files include="JsonSchemas\*.json" buildAction="Content" copyToOutput="true" flatten="false" />
</contentFiles>
</metadata>
<files>
<file src="JsonSchemas\*.*" target="content\JsonSchemas" />
</files>
</package>
Schema example:
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$defs": {
"ArrayItem": {
"type": "object"
}
},
"title": "dataset object",
"type": "object",
"properties": {
"Data": {
"type": "array",
"items": {
"$ref": "#/$defs/ArrayItem"
},
"default": []
}
},
"required": [ "Data" ]
}