Hari Priya Thangavel
Hari Priya Thangavel

Reputation: 517

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. 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

Answers (1)

karthickj25
karthickj25

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

enter image description here

2. Pass the path to your power shell script

enter image description here

enter image description here

make sure to set the working dir to your artifact drop location. This is where the powershell script will get executed

  1. You need pass the directory as a variable to your PowerShell script, here it is 'appManifestFile'

    enter image description here

  2. PowerShell script to add append node with '$appManifestFile' as var
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

Related Questions