I have an Azure Function project. It includes local.settings.json configuration file with some secrets. Those values are retrieved and used by the xUnit testing project. Everything works well when run on Visual Studio, but in the Azure build pipeline, the values are not injected, and the file contains original placeholder values. The local.settings.json file has Build Action as "Content", and Copy to Output Directory as "Copy if newer". In the pipeline, I use a File Transform task to inject values. Here is a part of my pipeline:
- task: FileTransform@1
inputs:
folderPath: '$(System.DefaultWorkingDirectory)/ProjectName'
fileType: 'json'
targetFiles: 'local.settings.json'
- task: DotNetCoreCLI@2
displayName: 'DotNet Build Projects'
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: --configuration $(buildConfiguration)
- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests'
inputs:
command: 'test'
projects: '**/ProjectName.Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/'
publishTestResults: true
What can I be doing wrong?