I was upgrading an Azure Durable Function Application from .NET 9 to .NET 10. Our Azure DevOps pipeline have a job that executes set of integration tests by spinning up the function using Azure Functions Core Tools (func.exe). Since we were using MSSQLLocalDB, the agent is Windows.
After the upgrade, the integration tests was failing to spin up func with a frustrating error.
You must install or update .NET to run this application.
App: D:\a\1\s\tests\...\bin\Debug\net10.0\FunctionApp.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '10.0.0' (x64)
.NET location: C:\Program Files\dotnet\
The following frameworks were found:
8.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
8.0.21 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
9.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
9.0.10 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
The pipeline uses the UseDotNet@2 task to install .NET 10.
- task: UseDotNet@2
displayName: Install .NET 10.0.x
inputs:
packageType: 'sdk'
version: '10.0.x'
The pipeline debug logs showed UseDotNet@2 task was setting DOTNET_ROOT and updating PATH correctly:
##[debug]Absolute path for pathSegments: C:\hostedtoolcache\windows\dotnet\sdk
Successfully installed .NET Core sdk version 10.0.100.
##[debug]Processed: ##vso[task.prependpath]C:\hostedtoolcache\windows/dotnet
##[debug]set DOTNET_ROOT=C:\hostedtoolcache\windows/dotnet
| dotnet --info |
When starting the worker process, it ignores:
- The DOTNET_ROOT environment variable
- The PATH environment variable
Since .NET 10 isn't yet pre-installed on DevOps agents, Azure Functions
can't find it.
After trying different things, the solution came out simple.
When installing .NET 10, override the default installation path which is $(Agent.ToolsDirectory)/dotnet (C:\hostedtoolcache\windows\dotnet in Windows) to C:\Program Files\dotnet where Azure Functions expects to find it.
- task: UseDotNet@2
displayName: Install .NET 10.0.x
inputs:
packageType: 'sdk'
version: '10.0.x'
installationPath: 'C:\Program Files\dotnet'
And that did it.
Hope this helps.
Happy Coding.
Regards,
Jaliya