Open snarodev opened 7 months ago
Interesting.. I got the same error while using Azure Pipelines VSBuild:
Done Building Project "C:\Users\VssAdministrator\AppData\Local\Temp\1jdz0xj2.hba\WorkerExtensions.csproj" (Build target(s)).
##[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.azure.functions.worker.sdk\1.16.2\build\Microsoft.Azure.Functions.Worker.Sdk.targets(180,9): Error MSB4018: The "EnhanceExtensionsMetadata" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\a\1\a\.azurefunctions\extensions.json'.
Server stack trace:
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 System.IO.File.ReadAllText(String path)
at Microsoft.Azure.Functions.Worker.Sdk.Tasks.EnhanceExtensionsMetadata.Execute() in D:\a\_work\1\s\sdk\Sdk\Tasks\EnhanceExtensionsMetadata.cs:line 29
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Same for me while using Azure Pipelines VSBuild with dotnet-isolated --target-framework net7.0. I tried with Microsoft.Azure.Functions.Worker.Sdk 1.13.0 and 1.16.0
2023-12-06T16:41:22.6632061Z ##[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.azure.functions.worker.sdk\1.16.0\build\Microsoft.Azure.Functions.Worker.Sdk.targets(180,9): Error MSB4018: The "EnhanceExtensionsMetadata" task failed unexpectedly.
System.IO.FileNotFoundException: Could not find file 'D:\a\1\s\Ascend.Functions\bin\Release\net7.0\.azurefunctions\extensions.json'.
File name: 'D:\a\1\s\Ascend.Functions\bin\Release\net7.0\.azurefunctions\extensions.json'
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.File.ReadAllText(String path, Encoding encoding)
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.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
Is there any resolution for this issue? I've spent most of today trying to find some resolution for this. I have uninstalled both .NET and Rider, reinstalled them, and tried creating a brand new Functions solution only to be met with this error. I am unable to work on my Functions project with this error.
I'm not certain what step of the process fixed this issue, but I was able to resolve the error after these steps:
i ran into what appears to be the same problem but without the involvement of the /p:OutDir
parameter.
see https://github.com/Azure/azure-functions-dotnet-worker/issues/2291.
I am facing the same issue when building function app project targeting .NET 8 in isolated model in Azure DevOps pipeline. The project build fine in local environment but gives this error in Azure DevOps pipeline. I have added steps for installing both .NET 6 and .NET 8 in the ADO pipeline but still facing the same issue. What is the solution to this problem?
Here is the error message : ##[error]C:\Users\VssAdministrator.nuget\packages\microsoft.azure.functions.worker.sdk\1.17.2\build\Microsoft.Azure.Functions.Worker.Sdk.targets(190,9): Error MSB4018: The "EnhanceExtensionsMetadata" task failed unexpectedly. System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\a\1\b\publish_output.azurefunctions\extensions.json'.
@pkpaul5 I worked around the problem by not setting an output directory. The build artifacts will then be placed in the default location bin\...\
.
@markuspalme Thanks for your suggestion. I am able to work around the problem by not setting output directory.
I was able to build in Azure Pipelines with 1.17.2. I was having issues also but got it resolved.
Hope this helps! https://github.com/Azure/azure-functions-dotnet-worker/issues/2291#issuecomment-2057575535
Setting the
OutDir
option with msbuild causes a Isolated Function build to fail.How to replicate:
func init LocalFunctionProj --worker-runtime dotnet-isolated --target-framework net6.0
)msbuild "path/to/the/solution" /p:OutDir="some/other/output/folder"
in the Developer Command PromptThe build then fails. When
OutDir
is not specified, theextensions.json
file is created in the Temp folder and then copied, but whenOutDir
is specified theextensions.json
file is created in the output folder, but then the next step then looks for the file in the.azurefunctions
folder.Example output of the relevant build log parts without the OutDir option (Command
msbuild "C:\Users\jms\Desktop\DeleteNow\FunctionApp1\FunctionApp1.sln"
-> Build works):Relevant build log part with the OutDir option (Command:
msbuild "C:\Users\jms\Desktop\DeleteNow\FunctionApp1\FunctionApp1.sln" /p:OutDir=C:\Users\jms\Desktop\test\test2
-> Build fails):