[英]How to modify the application manifest in VSTS release pipeline?
I have to add additional parameter to application manifest xml file while deploying to cluster. 部署到集群时,我必须向应用程序清单xml文件添加其他参数。 There is a release pipeline configured in VSTS to which I have to add a task.
在VSTS中配置了一个发布管道,我必须向其中添加任务。
How to achieve this ? 如何实现呢? Should I have to use Powershell inline script ?
我是否必须使用Powershell内联脚本? If so how can I modify file in the artifact directory ?
如果是这样,如何修改工件目录中的文件?
@Karthick, Thanks for your answer , but I am facing issues while saving the xml. @Karthick,谢谢您的回答,但是在保存xml时遇到了问题。 I did set the Working folder as $(build.artifactstagingdirectory)
我确实将工作文件夹设置为 $(build.artifactstagingdirectory)
$appManifestFile = $(build.artifactstagingdirectory)\pkg\ApplicationManifest.xml
$xml = (Get-Content $appManifestFile) -as [Xml]
$newNode = $xml.CreateElement("Parameter")
$newNode.SetAttribute("Name","Test")
$newNode.SetAttribute("Value","Test")
Write-Host $newNode
$xml.ApplicationManifest.Parameters.AppendChild($newNode)
$xml.Save($appManifestFile)
As you can see, I am accessing the file directly from the artifacts and then modifying it. 如您所见,我直接从工件访问文件,然后对其进行修改。 This script works fine locally, but in pipeline the file remains unchanged.
该脚本在本地运行良好,但是在管道中文件保持不变。 Am I missing out something?
我错过了什么吗?
You can use the build events to do that How to: Specify Build Events (C#) 您可以使用构建事件来执行此操作: 如何:指定构建事件(C#)
OR 要么
If you wish to do the same with VSTS build pipeline, you can add a powershell buid step by 如果您希望对VSTS构建管道执行相同的操作,则可以逐步添加Powershell Buid
1. Get the path to your artifact drop location 1.获取到工件放置位置的路径
2. Pass the path to your power shell script 2.将路径传递到您的Power Shell脚本
make sure to set the working dir to your artifact drop location. 确保将工作目录设置为工件放置位置。 This is where the powershell script will get executed
这是执行PowerShell脚本的地方
param ( [string]$appManifestFile = "" ) $appManifestFile = $appManifestFile + "\\app.manifest" echo "the path is set to : $appManifestFile" $xml = (Get-Content $appManifestFile) -as [Xml] $newNode = $xml.CreateElement("Parameter") $newNode.SetAttribute("Name","Test") $newNode.SetAttribute("Value","Test") $xml.DocumentElement.AppendChild($newNode) $xml.Save($appManifestFile)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.