Reputation: 517
I have to add additional parameter to application manifest xml file while deploying to cluster. There is a release pipeline configured in VSTS to which I have to add a task.
How to achieve this ? Should I have to use Powershell inline script ? 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. I did set the Working folder as $(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?
Upvotes: 2
Views: 2118
Reputation: 1197
You can use the build events to do that How to: Specify Build Events (C#)
OR
If you wish to do the same with VSTS build pipeline, you can add a powershell buid step by
1. Get the path to your artifact drop location
2. Pass the path to your power shell script
make sure to set the working dir to your artifact drop location. This is where the powershell script will get executed
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)
Upvotes: 3