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

Including a Folder in NuGet Package and have it install into project as file .netcore/Razor

$
0
0

I am using Visual Studio 2019 and creating NuGet packages successfully with this method:

https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio?tabs=netcore-cli

All going well, but there are some settings (.json) files contained within a directory PageSettings/

When I publish my NuGet package and then install it into a new project, this directory appears in VS as a linked item (see pic). So as a user I can access the files, but they don't "exist" when the project is run.

enter image description here

This means if I run this project without physically copying and adding these files I get ArgumentException: The directory name 'Path-To-project\pagesettings' does not exist. (Parameter 'Path')

I can see why this is happening, but can't work out how to change it, or if it is possible.

The article linked above suggests adding code to the csproj file like:

<ItemGroup><Content Include="readme.txt"><Pack>true</Pack><PackagePath>\</PackagePath></Content></ItemGroup>

But that doesn't work and in fact seems unnecessary since the Pack command is including my files, just not creating them properly when installing.

Also - it would be extremely handy if there was a way to tell VS to prompt whether to install this file or not. Since it is settings, if a user changes the settings and then later installs an updated version of my NuGet package I would not want it to overwrite their customised settings... perhaps this is why the link design happens... if so, if someone could confirm?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



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