nuget pack on csproj for readme.txt not behaving as expected
Is there a way to get nuget to pick up the readme.txt file included in a .csproj using "nuget pack " so that when the package is installed the readme.txt file opens up automatically in VS?
When I create the nuspec by hand and list the readme.txt in the section such that the readme.txt file resides at the same level as the nuspec file, running nuget pack on the nuspec does the right thing.
When using nuget pack on the .csproj though the behavior is such that the readme file of the project gets included in the "Content" folder instead. In this case, is there a way to get nuget pack to include the readme file in the section so that it behaves identical to creating the nuspec manually and adding the readme.txt at the root of the folder
Yes, you need to do a few things. Let's assume your project is called MyProject.
content
folder when you package the csproj. MyProject.nuspec
file, create one in the same folder as MyProject.csproj
. This should use the replacement tokens defined in Creating And Publishing A Package ($id$, $version$, etc.) to avoid duplicating anything specified in the project itself (eg, in AssemblyInfo.cs). <files>
section in the nuspec file, containing only readme.txt
, like this: <files> <file src="readme.txt" target="" /> </files>
Having done this, when you run nuget pack MyProject.csproj
, it will place readme.txt at the package root and will create the appropriate lib
folder for your DLL(s). Installing the package will open the readme.txt automatically without adding it to the target project as content.
I've tested this with NuGet 2.8.60717.93.
链接地址: http://www.djcxy.com/p/24290.html上一篇: 只有在别人不在时才运行任务