Powershell 如何在构建工件中引用文件

Powershell 如何在构建工件中引用文件,powershell,azure-devops,Powershell,Azure Devops,我有一个从构建管道创建的发布管道。创建的工件有一个PowerShell函数——该函数基于template.json文件在Azure中部署一组资源组。因此,我需要执行新的AzDeployment并从构建工件传入template.json 我尝试过使用$(Build.SourcesDirectory)和其他变量,但是powershell出现了错误,因为它不知道这是什么 New-AzDeployment -Name "resourceGroupDeployment" `

我有一个从构建管道创建的发布管道。创建的工件有一个PowerShell函数——该函数基于template.json文件在Azure中部署一组资源组。因此,我需要执行新的AzDeployment并从构建工件传入template.json

我尝试过使用$(Build.SourcesDirectory)和其他变量,但是powershell出现了错误,因为它不知道这是什么

New-AzDeployment -Name "resourceGroupDeployment" `
                 -TemplateParameterFile "$(Build.SourcesDirectory)/resourceGroup.Parameters.json" `
                 -TemplateFile "$(Build.SourcesDirectory)/resourceGroup.Template.json" `
有关发布管道中可用的默认变量,请参见


您要查找的是
$(System.ArtifactsDirectory)
变量。因此,当您将工件添加到发布管道中时,会设置类似于
“$(System.ArtifactsDirectory)\n的内容。

您可能会添加错误消息-所有错误消息-以便有人能够对原因进行有根据的猜测。[grin]