Azure DevOps Pipeline & local.settings.json

I’ve been having an issue with a F# project I’ve inherited. It had included the local.settings.json in the repository and was copying it during the AzureDevOps Pipeline.

Since the file should not be included in the repository, I added it to the .GitIgnore file and set settings in the project file to:

<None Include="local.settings.json">
   <CopyToOutputDirectory>Always</CopyToOutputDirectory>
   <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>

This was causing issues with DevOps when it was building the project because it couldn’t find the local.settings.json file.

It took me a bit of googling but I eventually found the answer and changed it to:

<None Include="local.settings.json" 
          Condition="Exists('local.settings.json')">
   <CopyToOutputDirectory>Always</CopyToOutputDirectory>
   <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>

Leave a comment