The Function App build is failing with DirectoryNotFound exception

Siddartha Cherukumudi 0 Reputation points Microsoft Employee
2025-04-17T07:12:42.9666667+00:00

I am using Azure.Function.Worker.SDK version 1.17.2 but when I try to build Function App locally I am getting the following error

Severity    Code    Description Project File    Line    Suppression State Error (active)    MSB4018 The "EnhanceExtensionsMetadata" task failed unexpectedly. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\scherukumudi\git\MCFR\target\Debug\AnyCPU\src\Microsoft.Retail.ShopperCopilot.FunctionApp\Debug\.azurefunctions\extensions.json'.    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)    at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)    at Microsoft.Azure.Functions.Worker.Sdk.Tasks.EnhanceExtensionsMetadata.Execute() in D:\a\_work\1\s\sdk\Sdk\Tasks\EnhanceExtensionsMetadata.cs:line 29    at Microsoft.Build.Framework.ITask.Execute()    at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()    at Microsoft.Build.BackEnd.TaskBuilder.

I checked the following github discussion https://github.com/Azure/azure-functions-dotnet-worker/issues/2291 and tried following the exact steps but no avail

But somehow the same Function App in my Devbox build is successful

The dotnet version I am using is: 8.0.408

I even tried doing the following

I uninstalled and reinstalled the Visual Studio

I reinstalled dotnet version

I cleared the nuget caches

But I am still stuck with this issue

Please help me unblock this issue

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,745 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.