user1877936
user1877936

Reputation: 363

How to replace value inside XML in tasks pipeline using variables?

How can I update the filename attribute below using a variable?

I added a Replace Transmission task, but how to update the values (filename="y.zip", based on my variable) inside an .xml file using pipeline tasks?

<?xml version="1.0" encoding="utf-16"?>
<configdata>
  <solutions>
    <configsolutionfile filename="x.zip" />
  </solutions>
</configdata>

Upvotes: 1

Views: 5995

Answers (2)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35514

Krzysztof Madej is correct. And I would also like to add the following points.

  1. Here is an extension: XDT Transform. This extension contains the "XDT Transform" task. This task also supports to transform XML file transformation.

  2. You also could try to use "File transform " task.

  3. If you want to deploy the application to Azure or IIS , the Azure App Service Deploy task and IIS Web App Deploy task support file transforms and variable substitution.

Hope this helps.

Upvotes: 0

Krzysztof Madej
Krzysztof Madej

Reputation: 40849

You have few options:

It all actually depends at which stage you want to achieve and what you have already. If you want to do it before generating package I would recommend first option - token replace. If you want to do it after (= just before publishing the package) and you have already config transformation files, you can go with XML transformation. Last one is convinient if you don't want to use tranformation files and you want to do it just before publishing the package.

Upvotes: 3

Related Questions