如何将文件夹添加到 nuspec 文件 [英] How to add a folder to a nuspec file

查看:23
本文介绍了如何将文件夹添加到 nuspec 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我实际上是在尝试将一个网站项目(不是 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:

  1. 要么手动创建 .nuspec,要么从 .csproj 或现有程序集生成一个(请参阅 文档).
  2. 以上一步中创建的 .nuspec 作为参数调用 nuget pack.
  1. Either create a .nuspec manually, or generate one from a .csproj or existing assembly (see nuget spec in the docs).
  2. Call nuget pack with the .nuspec created in the previous step as a parameter.

由于您周围没有 .csproj,因此您无法手动创建 .nuspec(或使用诸如 NuGet 包资源管理器).

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="binRelease***.*" target="content" /> 
</files>

这会将 binRelease 文件夹的所有文件和(递归)子文件夹放入 NuGet 包的 content 文件夹中.

This will take all the files and (recursive) sub-folders of the binRelease 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆