Confirm that package contains content file(s)
If you are uncertain about whether a content file is being included in a nuget package, then you can quickly confirm this by opening the .nupkg
package file and attempting to locate the content files that you are trying to include. According to the documentation:
Technically speaking, a NuGet package is just a ZIP file that's been
renamed with the .nupkg extension and whose contents match certain
conventions.
Since you have set the build action for your file to Content
(as you indicated above), you should expect to find it there, likely in both the content
and contentFiles
directories. (For future reference, you may find it useful to acquaint yourself a bit with the internal structure/conventions of nuget packages.)
Once you have confirmed that your content file is contained in your package, then it seems you only need to figure out how to access the contents of that file.
Option 1: Access content file from a Nuget package from within another project
If you want to be able to reference the content file which is contained in the Nuget package from another project, then first add the Nuget package reference to the new project. Once you do this, you should see the content file(s) included by the package show up in the referencing project. At this point, you can now set the Build Action and Copy to Output Directory options as you normally would, just as though you had added those files directly to the referencing project.
Here is an example of this being done using Visual Studio 2017:

In the example above, TestLib
is a .net core 2.0 class library which only contains a directory with 2 files. Each has a Build Action
of Content
and a Copy to Output Directory
value that corresponds to its name. A nuget package was created from TestLib
and subsequently referenced by the ConsoleApp
project. The Content
directory from the TestLib
project (with all of its files) shows up in the ConsoleApp
project automatically once the package reference is added. However, by default the Copy to Output Directory
option will be set to "Do not copy" for all content files, so you will likely wish to change this, based on your project file snippet above.
If, however, your requirements don't allow you to change the Copy to Output Directory
option on the content file from the referencing project, and you wish for it to be set by default to Always
instead of Never
, then I'll refer you to this SO answer for how to accomplish that. (Hint: If you are not already using a .nuspec
file, then you can copy the auto-generated one from within the .nupkg
file to use as a starting point.)
[Unlikely] Option 2: Access content file from a Nuget package directly
If you wanted to access the content file from the Nuget package directly, then you could automate the process of extracting the content file(s) from the .nupkg
file and doing with it according to your needs. I don't think this is what you wanted, but I imagine that someone has wanted to do this before.
Even if this hasn't given you the answer you were seeking, I hope this has helped in some way.