Search code examples
jsonazure-devopsappsettingsnotepadline-endings

Release Pipeline task File Transform converts line endings to Unix


I am using File Transfrom in Azure DevOps to transform an application's appsettings.json file, with JSON option, in Release Pipeline.

The transform occurs and replaces variables as expected. When opening up the appsettings file in notepad on the server, the JSON formatting has ended up on a single line. After further investigation, noticed that the line endings have changed during transformation. Specifically from Windows line endings to Unix line endings. Could anyone advise why this may have happened?

Trying to replicate the issue on another Azure Devops instance, the issue did not occur. Not sure what the difference between instances are to cause this. I am currently using Version 1 of the File Transform task, same issue occurs in Version 2 (Preview).

As a temporary fix I am running a PowerShell script to convert the line endings back to Windows after the transform, but that is not ideal.

This issue may be related to this closed report, no solution there.


Solution

  • After raising my own support request and not finding a solution, realised that the issue in my case was viewing the JSON in notepad on the server. Windows 2012 Servers ship with an older version of notepad and that version cannot handle unix line-endings. So the issue did not lie with File Transform. Could paste contents into notepad++ or install notepad++ on the server if that is an option.