I am trying to create a .NET standard nuget package of content files (with no managed assemblies), to be consumed by .NET Framework assemblies. My aim is to get this folder of files copied to the bin folder of the consuming assembly.
This question is similar Add native files from NuGet package to project output directory (and uses this nuget package http://www.nuget.org/packages/Baseclass.Contrib.Nuget.Output/), but I require my nuget package to be .NET Standard
I have added the files in the assembly under contentfiles\any\any\myfiles and added the following to the metadata section of the nuspec file:
<contentFiles>
<files include="any/any/myfiles/*" buildAction="None" copyToOutput="true" />
</contentFiles>
When I try to add this to a .NET framework assembly I get the error
Could not install package 'myPackage 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I have also tried adding the files to the root of the project and adding the following beneath the metadata element in the nuspec file:
<files>
<file src="myfiles\**\*" target="myfiles" />
</files>
Full nuspec file:
<?xml version="1.0"?>
<package>
<metadata>
<id>myPackage</id>
<version>1.0.0</version>
<title>myPackage</title>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>my files/description>
<releaseNotes></releaseNotes>
<tags></tags>
<contentFiles>
<files include="any/any/myfiles/*" buildAction="None" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="myfiles\**\*" target="myfiles" />
</files>
</package>
Also, in the csproj I've also changed the TargetFramework element to:
<TargetFrameworks>netstandard1.3;netstandard2.0;net40;net45;net46</TargetFrameworks>
SOLUTION:
In the end, this is the solution: "myFiles" is a folder that sits in the project root and contains many different files and sub-directories.
nuspec file:
<?xml version="1.0"?>
<package >
<metadata>
<id>myPackage</id>
<version>1.0.0</version>
<title>My Package</title>
<tags></tags>
<dependencies>
<group targetFramework=".NETStandard2.0" />
<group targetFramework=".NETFramework4.6.2" />
</dependencies>
<contentFiles>
<!-- this sets "CopyIfNewer" on all files in the project that references this package -->
<files include="**/*" buildAction="None" copyToOutput="true"/>
</contentFiles>
</metadata>
<files>
<file src="myFiles\**\*" target="contentFiles\any\any\myFiles"/>
</files>
</package>
The project that references the nuget package will appear to have a folder called "myfiles" (with a link icon over all the files) which will get copied to the bin folder on build.