Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileTransForm@2 is throwing 'Cannot perform XML transformations on a non-Windows platform' for a json transformation

Since I'm getting The FileTransform@1 task is deprecated, please use a newer version of the FileTransform task warning for my pipelines I updated FileTransform@1 to FileTransform@2 See the code below.

- task: FileTransform@2
  displayName: 'Update the parameters in azuredeploy.web.parameters.json'
  inputs:
    folderPath: '**/'
    targetFiles: '**/azuredeploy.web.parameters.json'
    fileType: json

But that failed with error Cannot perform XML transformations on a non-Windows platform when it's an Json transformation.

like image 669
user26955403 Avatar asked Oct 12 '25 12:10

user26955403


2 Answers

Found out by trial and error that if you only want JSON variable substitution, you need to explicitly specify the "xmlTransformationRules", but leave it blank in order to disable XML transformations:

- task: FileTransform@2
  displayName: 'Update appSettings.json'
  inputs:
    folderPath: '**/'
    xmlTransformationRules: 
    jsonTargetFiles: 'appSettings.json'
like image 105
David Guerra Avatar answered Oct 16 '25 07:10

David Guerra


I saw in documentation that in version @2 the xmlTransformationRules has a default value, even if I don't use it. So I gave it empty string ''. I think it tries behind the scene to do some xml File Transformations, and sometimes you only need Variables Substitution.

folderPath field I would say its where the azuredeploy.web.parameters.json resides.

- task: FileTransform@2
  displayName: Transform appsettings file
  inputs:
    folderPath: './src/MyProject/folder'
    xmlTransformationRules: ''
    jsonTargetFiles: '**/azuredeploy.web.parameters.json'
like image 31
Mihai Socaciu Avatar answered Oct 16 '25 05:10

Mihai Socaciu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!