如何将文件夹添加到nuspec文件 [英] How to add a folder to a nuspec file
问题描述
所以我实际上是在尝试将一个网站项目(不是Web应用程序,因此没有csproj文件)打包成一个NuGet包,以供Octopus使用,但又碰到了一个砖墙.
So I'm actually trying to package up a web site project (not web application so no csproj file) into a NuGet package ready for Octopus to consume but am running into one brick wall after another..
我研究过使用OctoPack,但它不支持网站项目,仅支持Web应用程序项目.
I looked into using OctoPack but it doesn't support web site projects only web application projects.
我现在正在尝试找到一种将文件夹(以我的情况为网站)添加到Nuget包中的方法,但是Nuget不允许通过命令行这样做吗?它还需要一个.csproj文件!
I am now trying to find a way of adding a folder (in my case a web site) into a Nuget package but Nuget doesn't allow this via the command line does it? It also requires a .csproj file!
我还尝试创建NuGet规范文件并将其传递到文件夹中,但是不可能吗?
I've also tried trying to create the NuGet spec files and pass it in a folder but not possible?
目前,我可能必须使用NuGet软件包资源管理器,但是我想编写脚本.
For the moment I may have to use the NuGet package explorer but I want to script this.
我已经看过这个问题,但似乎无法解决我的问题 我是否可以创建没有项目文件的nuget包
I've looked at this question but doesn't seem to handle my scenario Can I create a nuget package without a project file
那么,有谁知道如何通过命令行将文件夹最好地添加到NuGet包中?!
So does anyone know how to best add a folder to a NuGet package via the command line!?
推荐答案
我不知道OctoPack,但是使用nuget.exe,打包过程分为两个步骤:
I don't know OctoPack, but with nuget.exe, packaging is done in two steps:
- Either create a .nuspec manually, or generate one from a .csproj or existing assembly (see
nuget spec
in the docs). - Call
nuget pack
with the .nuspec created in the previous step as a parameter.
由于没有.csproj,因此您无法手动创建.nuspec(或使用
Since you don't have a .csproj lying around, you're stuck creating the .nuspec manually (or with a GUI tool like NuGet Package Explorer).
您可以在 Nuspec参考中阅读有关如何创建.nuspec文件的所有信息. a>,特别是关于指定要包含在包中的文件的部分.
You can read all about how to create a .nuspec file in the Nuspec Reference, specifically the section about Specifying Files to Include in the Package.
如果要在包中包括一个文件夹(递归?),则需要在XML中添加如下内容:
If you want to include a folder (recursively?) in the package, you need to add something like this to the XML:
<files>
<file src="bin\Release\**\*.*" target="content" />
</files>
这将获取bin\Release
文件夹的所有文件和(递归)子文件夹,并将它们放在NuGet软件包的content
文件夹中.
This will take all the files and (recursive) sub-folders of the bin\Release
folder and put them in the content
folder of the NuGet package.
我不知道OctopusDeploy在软件包中应该采用哪种格式,但这就是您在软件包中包含文件夹的方式.
I have no idea what format OctopusDeploy expects in the packages, but that's how you include a folder in the package.
编辑: OctoPack自述文件.
这篇关于如何将文件夹添加到nuspec文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!