Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Could not install embedded files and folders in nuget package

$
0
0

I was experimenting on a nuget package project in Visual Studio 2022 Community Edition and my goal is to add a folder and a file to the nuget package which it would install in the root folder of the target project. It did not work. I don't know what was missing in the nuspec file but here are the steps I did:

  1. I've created 2 new C# Class library projects in .net 8 and named them MyPackage and TargetLibrary.
  2. I've created a contentFiles folder in the MyPackage project and added a test.js file inside it. Here is the test.js file:
 alert("it works!");
  1. I've added a simple icon.png and created a MyPackage.nuspec file in the project root:
<?xml version="1.0"?><package>   <metadata><id>MyPackage</id><version>3.0.6</version><description>A content sample package.</description><authors>Solomio Sisante</authors><owners>Solomio Sisante</owners><requireLicenseAcceptance>true</requireLicenseAcceptance><license type="expression">MIT</license><tags>content contentFiles</tags><icon>icon.png</icon><!-- Build actions for items in the contentFiles folder --><contentFiles><!-- Include Assets as Content --><files include="**/contentFiles/*.*" buildAction="None" copyToOutput="true" flatten="true" /></contentFiles>   </metadata>   <files>   <file src="contentFiles\**" target="contentFiles" /> <file src="icon.png" target="icon.png" />   </files> </package>
  1. Finally, I created the package by running the nuget pack command:

    nuget pack Mypackage.nuspec -OutputDirectory bin\Release

When I tried to install it, it did not create the contentFiles folder or the test.js file.What am I missing here?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>