使用 Powershell 脚本发布 nuget 包 - 脚本未打包

Publising nuget package with Powershell scripts - scripts are not packaged

我正在使用 Visual Studio Team Services 打包一个文件夹和 pr 文档我添加了一个内容文件夹,还尝试使用 contentFiles 文件夹,其中包含另一个文件夹,然后是我的 powershell 脚本。包已创建,但内容文件夹未打包。

结构就像/content/ReleaseScripts/MyScript.ps1

如果直接打包项目文件,需要将文件的Build Action改为Content。 (在 VS 中右键单击文件 > 属性 > 将生成操作更改为内容)

如果只是在文件夹中创建.nuspec文件(没有工程文件,比如.csproj),然后打包这个.nuspec文件,可以参考以下步骤:

  1. Nuget.exe 工具添加到源代码管理并映射到构建代理(相同的文件夹级别(内容文件夹)需要打包)或者添加到build agent service account的环境变量(path)中
  2. 添加命令行任务(工具:nugget.exe;参数:spec;工作文件夹:[same level path that you need to package, such as the folder path that contains content folder]
  3. 添加 NuGet Packager 任务(要打包的 csproj 或 nuspec 文件的路径:**\*.nuspec