azure-devops - 在 Azure DevOps 构建管道中传递 NuGet 'Pack' 参数
问题描述
在我的 Azure DevOps 构建管道中,我添加了一个打包命令类型(版本 2.*)的 NuGet 任务。
我正在尝试传递-Exclude ***.tt
参数,以便在从其他项目引用时排除这些文件。但是,在生成的 NuGet 包中,这些 .tt 文件出现在 Content 文件夹中。
主机日志中写入的命令为:
nuget.exe pack PROJECTNAME.csproj -NonInteractive -OutputDirectory SOME_OUTPUTPATH -Properties "Configuration=release;\"-Exclude ***.tt\"" -Verbosity Detailed
如您所见, exclude 不是属性的一部分,但应该作为单独的-Exclude
参数。
知道如何实现这一目标吗?非常感谢!
添加了截图和 YAML:
steps:
- task: NuGetCommand@2
displayName: 'NuGet pack'
inputs:
command: pack
packagesToPack: ProjectName.csproj
buildProperties: '-Exclude ***.tt'
解决方案
当您使用-Exclude
时,nuget pack .csproj
您需要提供排除文件的完整路径。但是这里还有另一个问题,Azure DevOps 将 附加-Exclude
到-Properties
并且它忽略了排除,所以我们需要以-Exclude
另一种方式添加,如何?在 NuGetcustom
命令中:
- task: NuGetCommand@2
inputs:
command: custom
arguments: 'pack "$(Build.SourcesDirectory)\Path\To\.csproj" -Exclude "$(Build.SourcesDirectory)\Path\to\*.tt"'
这是您尝试的常规日志-Exclude
,您可以看到 nuget 打包了我的.exe
文件:
在我制作自定义命令后,这里有一个日志,没有.exe
:
我的任务是:
- task: NuGetCommand@2
inputs:
command: custom
arguments: 'pack "$(Build.SourcesDirectory)\TestVars\TestVars\TestVars.csproj" -Exclude "$(Build.SourcesDirectory)\TestVars\TestVars\bin\Debug\*.exe"'
推荐阅读
- electron - 电子:初始化前无法访问对话框
- python - 如何使烧瓶路线可用于苗条而不是最终用户
- common-lisp - 更改 asdf 中已编译文件的路径?
- python-3.x - 尝试更改屏幕时出现 Kivy 错误
- python - 打印相关矩阵的下半部分但保留索引名称
- php - 在 Laravel 中选择不验证
- python - 以有效的方式从子列表列表中删除第一个元素[python 3]
- javascript - 蒸汽 3 叶中的 Javascript 函数 - 帮助需要
- rdf - 您如何确定谓词“方向”?
- google-apps-script - 有没有办法让 Google 电子表格上的每个人都敬酒?