Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Debug can't find launchable target with MacOS apps #549

Open
andrews4s opened this issue Sep 21, 2023 · 11 comments
Open

[BUG] Debug can't find launchable target with MacOS apps #549

andrews4s opened this issue Sep 21, 2023 · 11 comments
Labels
area-maui area-project Project load, Solution Explorer enhancement New feature or request mac MacOS triaged The issue has been triaged
Milestone

Comments

@andrews4s
Copy link

Describe the Issue

Attempting to debug an app targetting net7.0-macos fails with the error:

"{projectname}.csproj" does not support debugging. No launchable target found.

Steps To Reproduce

  1. Open a terminal
  2. mkdir mactest
  3. cd mactest
  4. dotnet new macos
  5. code .
  6. Right-click the project and select Debug>Start New Instance

Expected Behavior

The app launches with the VS Code debugger attached.

Environment Information

-OS: MacOS 13.4.1
-VS Code: 1.82.2
-Extension Version: v2.2.10

@andrews4s andrews4s added the bug Something isn't working label Sep 21, 2023
@microsoft-issue-labeler microsoft-issue-labeler bot added the area-dotnet-debugging Issues around .NET Debugging with console, ASP.NET, or Aspire label Sep 21, 2023
@webreidi webreidi added the mac MacOS label Sep 25, 2023
@WardenGnaw WardenGnaw added the area-project Project load, Solution Explorer label Sep 25, 2023
@WardenGnaw
Copy link
Member

@tmeschter The ILaunchConfigurationService is returning 0 projects with the macos template.

@WardenGnaw WardenGnaw removed the area-dotnet-debugging Issues around .NET Debugging with console, ASP.NET, or Aspire label Sep 25, 2023
@tmeschter
Copy link
Member

@andrew-tavera @WardenGnaw What kind of project does dotnet new macos create?

@tmeschter tmeschter added the needs-more-info Needing more information, waiting on OP label Oct 2, 2023
@andrews4s
Copy link
Author

andrews4s commented Oct 2, 2023

It generates an app using the net7.0-macos runtime (Mac desktop app). Manually adding a launch.json works if you treat it like a console app but change the "program" to go to the binary inside the .app bundle instead of the dll in the bin folder.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/bin/Debug/net7.0-macos/osx-x64/mactest.app/Contents/MacOS/mactest",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "console": "internalConsole"
        }
    ]
}

@tmeschter
Copy link
Member

@andrew-tavera Is this a MAUI project? Would you be able to provide an example project?

@andrews4s
Copy link
Author

mactest.zip
This is not a MAUI project. I've uploaded an example new project with a manually created launch.json/tasks.json. The second launch profile works but the debug option from the extension does not.

@tmeschter tmeschter removed the needs-more-info Needing more information, waiting on OP label Oct 3, 2023
@tmeschter
Copy link
Member

Thanks for that; I can see what's going on now.

The short answer is that C# Dev Kit is currently focusing support on a narrow set of project types: web applications, MAUI apps (in conjunction with the MAUI extension), and Unity apps (in conjunction with the Unity extension). This particular project falls outside the scope of what we support so we haven't gotten around to figuring out how it should work.

The long answer is that the MacOS SDK targets (Microsoft.macOS.Sdk.targets) pull in the Xamarin shared targets (Xamarin.Shared.Sdk.targets) which removes the "LaunchProfiles" capability. Currently all the launch targets in C# Dev Kit are based off the projects' launch profiles; with that capability turned off we have no way of knowing how to launch the project.

For the time being I see two options:

  1. Continue to use launch.json.
  2. Attempt to turn launch profiles support back on by adding the following to your project:
    <PropertyGroup>
      <_KeepLaunchProfiles>true</_KeepLaunchProfiles>
    </PropertyGroup>
    
    Setting this property will prevent the "LaunchProfiles" capability from being removed. I'm not entirely sure what will happen, though, as the default launch profile support doesn't know anything specific about launching macOS projects.

@tmeschter tmeschter added enhancement New feature or request and removed bug Something isn't working labels Oct 3, 2023
@andrews4s
Copy link
Author

Thanks for the explanation @tmeschter! Is there any documentation or public roadmap that shows what is supported now and planned? I'm trying to transition off VS4Mac since it is retiring.

@tmeschter
Copy link
Member

@andrew-tavera Here's the documentation on what is currently supported: https://code.visualstudio.com/docs/csharp/cs-dev-kit-faq#_what-project-types-are-currently-supported.

@kvenkatrajan
Copy link

related issue: #726

@datvm
Copy link

datvm commented Feb 5, 2024

I have this issue with MacCatalyst as well for an existing project. Does anyone know the "magic" that they add for newer project? New project works well but I have this solution with many projects (some of them cannot be compiled which is not a problem for my specific project).

Edit: found it, you need to choose a startup project over here at the bottom corner:
image

@emaf
Copy link
Member

emaf commented Nov 15, 2024

I'm assigning this to MAUI since the MAUI extension brings the support for .NET iOS and MacCatalyst, and should handle supporting macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-maui area-project Project load, Solution Explorer enhancement New feature or request mac MacOS triaged The issue has been triaged
Projects
None yet
Development

No branches or pull requests

8 participants