I am using this .nuspec file to create a nuget package.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>ClassLibrary1</id>
<version>1.0.0</version>
<title>Title</title>
<authors>Author</authors>
<owners>Owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<copyright>Copyright 2017</copyright>
<contentFiles>
<files include="any/any/myfile.xml" buildAction="None" copyToOutput="true" flatten="true" />
</contentFiles>
</metadata>
</package>
Using this configuration when creating a project that references this nuget package, the content files will be copied to the output folder. Now I am converting my project into a .Net core project, and I want to use project.json to create a nuget package and get rid of the .nuspec file. This is my .json project
{
"version": "1.0.0-*",
"dependencies": { },
"frameworks": {
"net452": {
}
},
"packOptions": {
"files": {
"mappings": {
"contentFiles/any/any/myfile.xml": "Configuration/myfile.xml"
}
}
},
"scripts": {
"postcompile": [
"dotnet pack --no-build --configuration %compile:Configuration%"
]
}
}
Now the problem is that when you create a project that references this nuget package, it will also try to compile the content file. And the assembly fails. How can I exclude contentFile from compilation?
source
share