Csproj's nuget pack for readme.txt doesn't behave as expected

Is there a way to get nuget to pick up the readme.txt file included in .csproj using the “nuget package” so that when the package is installed, the readme.txt file automatically opens in VS?

When I create nuspec manually and listed readme.txt in this section, so that the readme.txt file is at the same level as the nuspec file, it runs nuget pack on nuspec.

When using the nuget package in .csproj, although the behavior is such that the readme file of the project is included in the "Content" folder instead. In this case, is there a way to get the nuget package to include the readme file in the partition, so that it behaves identically to creating nuspec manually and adding the readme.txt file to the root of the folder

+7
nuget
source share
1 answer

Yes, you need to do a few things. Suppose your project is called MyProject.

  • Verify that in ActionScript (Read) the readme.txt property is set to None, not Content. This prevents it from being placed in the \content folder when packaging the csproj package.
  • If you do not already have a MyProject.nuspec file, create it in the same folder as MyProject.csproj . This should use replacement tokens defined in Creating and publishing a package ($ id $, $ version $, etc.) in order to avoid duplication of everything that is specified in the project itself (for example, in AssemblyInfo.cs).
  • Add the <files> section to the nuspec file containing only readme.txt , for example:
  <files>
     <file src = "readme.txt" target = "" />
   </files>

Having done this, when you run nuget pack MyProject.csproj it will place the readme.txt file in the root directory of the package and create the corresponding \lib folder for your DLL. Installing the package will automatically open the readme.txt file without adding it to the target project as content.

I tested this with NuGet 2.8.60717.93.

+3
source share

All Articles