Azure / Azure/azure-functions-dotnet-worker

Cannot debug net48 isolated worker in Visual Studio Code, debug works in Visual Studio 2022 with same project

Open
#2,967 0 comments 0 reactions 0 assignees View on GitHub
needs-investigation potential-bug
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

_(I made a github issue under vscode-azurefunctions with the same name [Cannot debug net48 isolated worker in Visual Studio Code, debug works in Visual Studio 2022 with same project](https://github.com/microsoft/vscode-azurefunctions/issues/4381#issue-2868510482) not knowing where the bug belong)_

As the title says, the net48 Microsoft Azure Isolated Worker sample project cannot be debugged in Visual Studio Code, but can be debugged in Visual Studio 2022. I've attached the project and added a `NetFxWorker.sln` and a `launch.json`, which is expected to make debugging work in Visual Studio Code.

*__Side note:__ I also tried the guide [Debugging when targeting .NET Framework](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=hostbuilder%2Cwindows#debugging-when-targeting-net-framework), where you manually start the function with `func host start --dotnet-isolated-debug` and in the `launch.json` use `"processId": "${command:pickProcess}"`, which makes you select the process from a list. That procedure did not work either, same result, i.e. no breakpoints are hit in VS Code.*

**Azure Functions Core Tools Version**: 4.0.6821
**Function Runtime Version**: 4.1036.1.23224

## Expected results in Visual Studio Code
- Symbols are loaded
- Break point is hit

## Actual result in Visual Studio Code
- No symbols are loaded
- Breakpoint is not hit

## Original sample project
This project comes without `NetFxWorker.sln` and a `launch.json`.
https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/NetFxWorker

Added files

### NetFxWorker.sln
```
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetFxWorker", "NetFxWorker.csproj", "{D4FFA174-29EF-4579-A27D-68530F607688}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "obj", "obj", "{8FDDA7E3-05A4-FA96-AE69-D8A8F706AC92}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug", "Debug", "{B0942149-7F10-7CFA-03EF-5E058D6ECE88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D4FFA174-29EF-4579-A27D-68530F607688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4FFA174-29EF-4579-A27D-68530F607688}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4FFA174-29EF-4579-A27D-68530F607688}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4FFA174-29EF-4579-A27D-68530F607688}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B0942149-7F10-7CFA-03EF-5E058D6ECE88} = {8FDDA7E3-05A4-FA96-AE69-D8A8F706AC92}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {50341679-8728-480E-BC88-B8306F779645}
EndGlobalSection
EndGlobal
```

### .vscode/launch.json
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Azure Function",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}",
"justMyCode": true
}
]
}
```

## Screenshots
### Actual result screenshot in Visual Studio Code
Image

### Actual result screenshot in Visual Studio 2022
Image

### Steps to reproduce

## Steps to reproduce on Windows 11
1. Extract the [NetFxWorker.zip](https://github.com/user-attachments/files/18903938/NetFxWorker.zip)
2. Open the folder with Visual Studio Code
3. Add a breakpoint in the `HttpFunction.cs` on line 23
4. Start Azurite
6. Start debugging (F5)
7. Open the `HttpFunction` link found in the terminal output
8. Wait for break point to be hit

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with samples/NetFxWorker/HttpFunction.cs at line 23 and the attached .vscode/launch.json and NetFxWorker.sln; reproduce the Windows 11 debugging steps with Azure Functions Core Tools and Azurite. Compare the VS Code behavior with Visual Studio 2022 and the documented manual process. Done means symbols load and the breakpoint is hit in VS Code.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, vscode
Domain
cloud, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.