azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

ADO build for Azure Function pipeline build fails - local.settings.json not found

Open rccnw opened this issue 5 years ago • 5 comments

Because local.settings.json is filtered by .gitignore it does not exist in the repository. But there is a reference to local.settings.json in the Function .csproj file. No problem locally, the file exists per template. But Azure DevOps pipeline builds fail. ('Error MSB3030 Could not copy the file...')

We solved this problem by adding a command task in the pipeline and emitting an empty local.settings.json file. This seems weird to have to do that and I can't find any discussion of this issue.

What is the recommended guidance to avoid this issue?

rccnw avatar Oct 06 '20 03:10 rccnw

@rccnw Can you try adding a condition? https://stackoverflow.com/a/44891913/3199781

anthonychu avatar Oct 06 '20 07:10 anthonychu

Thanks, didn't know about msbuild conditionals! I just gave that a try locally, and it doesn't seem to work. I tested by moving local.settings.json out of the folder temporarily.

Here is my updated .csproj section per the example :

` <ItemGroup>

  . . .

  <None Update="local.settings.json" Condition="Exists('local.settings.json')">

      <CopyToPublishDirectory>Never</CopyToPublishDirectory>

      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

</None>

</ItemGroup>`

rccnw avatar Oct 06 '20 19:10 rccnw

@rccnw are you still experiencing this issue?

apawast avatar Nov 11 '21 17:11 apawast

I've moved on from the job where I encountered that issue, so I don't have that setup at hand to easily test. But I did just create an new Azure Function project in VS2022 Current, and it appears the template creates exactly the same code as I reported a year ago.

Perhaps the MSBuild conditional technique you suggested earlier in this thread will work in a pipeline scenario, but it didn't for me at the time a year ago, maybe my error. As I noted, we hacked the pipeline by emitting an empty local.settings.json file as a pipeline step. That worked fine, but kind of silly.

I'm just guessing here, but I wonder if the MSBuIld Condition only applies to the declarations for that item, but despite the Condition statement, MSBuild still sees the reference to local.settings.json and doesn't like that the item wasn't there in the first place (having been properly filtered by .gitignore and never stored in the repo).

That's all I can offer now, thanks for pursuing this issue and the previous tip about build conditionals.

rccnw avatar Nov 11 '21 20:11 rccnw

Has there been any progress on this issue? Or is there a recommended work-around? We're currently trying to incorporate a Function App into our existing ADO Build Pipeline and this is blocking us at the moment. Cheers.

ajkimberley avatar May 10 '22 09:05 ajkimberley