Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET SDK Project Nuget Packaging: Add Tools Folder?

The new .NET SDK projects allow generating NuGet packages directly from various targets as part of the build process.

I realize that content is no longer allowed, but it looks like tools are still a viable option.

My scenario is that I need to distribute additional content after the package is installed - I understand this can't be done via NuGet anymore and that's fine. However, I want to show a Web page that has instructions for downloading and installing the additional assets.

Essentially I'd like to do something similar to what Newtonsoft.Json does:

enter image description here

I know you can use a powershell script to bring up a Web page, but is it possible to get that script into the NuGet package via the project build?

like image 295
Rick Strahl Avatar asked Oct 12 '25 09:10

Rick Strahl


1 Answers

m0sa answered the question I asked, but I wanted to add some additional information here on my actual usage scenario, which is displaying a readme file of some sort.

It turns out that Nuget supports adding a readme.txt file to the root folder of the Nuget package and if it finds that, it will be displayed. Note the file has to be named readme.txt - there's no support for other formats AFAIK.

enter image description here

While it's too bad you can't have a richer display, at least the text file activates links for clicking.

To do this:

enter image description here

  • Add a readme.txt file to the root of your project
  • Then Add this to your .csproj file:
<ItemGroup>
   <None Include="readme.txt" Pack="true" PackagePath="." />
</ItemGroup>

which causes the readme.txt file to be displayed when the package is installed as a primary package. Not displayed when the file is a dependency.

like image 186
Rick Strahl Avatar answered Oct 16 '25 10:10

Rick Strahl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!