'Nuget: in .net core library/sdk package, how to embed text files properly?

I have a .net core 3.1, or 2.1 library.

If I 'publish' to a folder, I get the project just fine. However, I want to add some text files that the project reads. So, I create a .nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <!-- Required elements-->
        <id>Project</id>
        <version>1.0.3</version>
        <description>(Testing-do not use)</description>
        <authors>me</authors>

        <!-- Optional elements -->
        <!-- ... -->
    </metadata>
    <!-- Optional 'files' node -->
    <files>
      <file src="App_Data\*.*" target="App_Data"/>
    </files>
</package>

(I also tried doing contentFiles, with None, and EmbeddedResource)

        <contentFiles> <!-- Include Assets as Content --> 
            <files include="**/App_Data/*.*" buildAction="EmbeddedResource" copyToOutput="true" flatten="true"/> 
        </contentFiles>

After the nuget -pack Project.csproj, it recognizes the .nuspec, and adds the files to the (zip), in the correct directory. However, after restoring that package in another project, those text files are not present anywhere - they aren't expanded/placed on disk.

How are they supposed to be specified so that the files all appear?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source