How to Stop a Backslash in appSetting.config Being Doubled

Viewed 327

I am new to Devops in general and am struggling to get a stage of my CI/CD Pipeline in Azure Devops to work correctly.

This is a full YAML CI/CD in the Pipelines section. I have not used the Classic mode in the Releases section.

I have the connection string saved as a Secret (Also tested with standard variable) Pipeline Variable Name of ConnectionStrings.DefaultConnection and a Value of Server=(localdb)\UK;Database=CustomerPortal;User ID =User;Password=SomePassword;Trusted_Connection=True;MultipleActiveResultSets=true

In my YAML I have tried:

- task: IISWebAppDeploymentOnMachineGroup@0
  displayName: 'IIS Web App Deploy'
  inputs:
    WebSiteName: '$(CurrentStagingSite)'
    Package: '$(Parameters.Package)'
    XmlVariableSubstitution: true
    JSONFiles: '**/appSettings.json'

And:

- task: FileTransform@1
  displayName: 'File Transform: '
  inputs:
    fileType: json
    targetFiles: '**/appSettings.json'
    folderPath: '$(Parameters.Package)'

Both have worked and substituted the Connection String from the variable to the appSetting.config JSON but the final package uploaded to the Website Location on the server contains this:

Connection String

"ConnectionStrings": {
        "DefaultConnection": "Server=(localdb)\\UK;Database=CustomerPortal;User ID=User;Password=SomePassword;Trusted_Connection=True;MultipleActiveResultSets=true"
    },

I am clearly doing something wrong or misunderstanding something, how do I stop the Transform from making it \\?

0 Answers
Related