Azure Pipeline将在Dotnet CLI任务中识别变量
我为管道有这些变量:
variables:
webProject: 'Company.Web'
dbProject: 'Company.Database'
然后,后来,我在dotnet cli任务中使用这些变量:
# stage/job setup
- task: DotNetCoreCLI@2
displayName: Clean
inputs:
command: custom
projects: '**/$(webProject).csproj'
custom: clean
arguments: '--configuration "$(BuildConfiguration)"'
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: custom
custom: restore
projects: |
'**/$(webProject).csproj'
'**/$(dbProject).csproj'
# rest of yaml
当我运行管道时,我会发现此错误:找不到匹配指定模式的项目文件。
奇怪的是,它对干净的任务有效,但是还原失败。我能够使用回声脚本确认变量正确渲染。我还可以用脚本中的变量文本替换变量,并且在这样做时运行良好。知道我在这里缺少什么吗?
I have these variables for my pipeline:
variables:
webProject: 'Company.Web'
dbProject: 'Company.Database'
And then later, I use those variables in a dotnet cli task:
# stage/job setup
- task: DotNetCoreCLI@2
displayName: Clean
inputs:
command: custom
projects: '**/$(webProject).csproj'
custom: clean
arguments: '--configuration "$(BuildConfiguration)"'
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: custom
custom: restore
projects: |
'**/$(webProject).csproj'
'**/$(dbProject).csproj'
# rest of yaml
When I run the pipeline, I get this error: Project file(s) matching the specified pattern were not found.
What is strange is it works ok for the clean task, but the restore fails. I was able to confirm with a echo script the variable is being rendered correctly. I also am able to replace the variable with the variable text in the script and it runs just fine when I do that. Any idea what I am missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然并未具体说明这一点,我期望这是因为您包括两个环球模式。您可以尝试
**/*。csproj
,也可以包括两个没有通配符的相对路径,即Although the documentation doesn't specifically state this, I'm expecting it's because you're including two glob patterns. You can either try
**/*.csproj
, or include two relative path with no wildcard characters, i.e.在文档中,有一个扩展地球解释了如何匹配多个项目。
如果您像我一样,只需要针对特定项目(仍在使用通配符)运行命令并保留变量/参数以进行模板,那么这就是要走的方法。
它如何对我有用:
In the documentation there is a section for Extended Globbing that explains how to match multiple projects.
If you are like me and only need to run a command against specific projects (while still using wildcards) and preserve variables/parameters for templating, this is the way to go.
How it worked for me:
如果使用模板,请尝试使用此sintax
传递变量。
Try to use this sintax
If you use templates, then you should pass the variable as a parameters from the azure-pipelines.yml