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

Unable to debug source generator: "The project doesn't know how to run the profile '<name>' with command 'DebugRoslynComponent'" #9547

Open
IanKemp opened this issue Oct 5, 2024 · 6 comments
Labels
Feature-Debugging Launching an application via F5, setting debug properties and launch profiles. Triage-Approved Reviewed and prioritized
Milestone

Comments

@IanKemp
Copy link

IanKemp commented Oct 5, 2024

Visual Studio Version

2022.17.11.4 (Community edition)

Summary

As title.

Suspect that the work done in dotnet/roslyn-sdk#896 for dotnet/roslyn-sdk#850 has either been reverted or broken.

Steps to Reproduce

  1. Clone https://github.com/riok/mapperly
  2. Attempt to debug source generator in Visual Studio by following https://mapperly.riok.app/docs/contributing/debugging/#integration-tests
  3. Get error
    image

Creating a new "Roslyn Component" launch profile is also not possible, as that option is missing from the "Launch Profiles" UI
image

Expected Behavior

Source generator debugging works

Actual Behavior

Source generator debugging does not work

User Impact

Can't debug source generators

@tmeschter
Copy link
Contributor

@IanKemp Do you have the ".NET Compiler Platform SDK" component installed in Visual Studio?

@drewnoakes
Copy link
Member

I assume Ian worked this out based on #9011 (comment).

Ian, I'm taking a look at that issue and think I have a solution so that users are prompted to install this automatically once the IsRoslynComponent project property is set to true.

@IanKemp
Copy link
Author

IanKemp commented Oct 8, 2024

@IanKemp Do you have the ".NET Compiler Platform SDK" component installed in Visual Studio?

I do, and I could've sworn I posted a screenshot showing that.

@drewnoakes drewnoakes added Feature-Debugging Launching an application via F5, setting debug properties and launch profiles. Triage-Investigate Reviewed and investigation needed by dev team labels Oct 10, 2024
@drewnoakes drewnoakes added this to the Backlog milestone Oct 10, 2024
@drewnoakes drewnoakes added Triage-Approved Reviewed and prioritized and removed Triage-Investigate Reviewed and investigation needed by dev team labels Oct 14, 2024
@drewnoakes
Copy link
Member

Confirmed that even with the .NET Compiler Platform SDK component installed, the launch profile fails to display in the editor, and the error is shown during run:

The project doesn't know how to run the profile with name 'IntegrationTests' and command 'DebugRoslynComponent'.

@drewnoakes
Copy link
Member

drewnoakes commented Oct 14, 2024

Launch profiles having command name DebugRoslynComponent are handled by Roslyn.ComponentDebugger.DebugProfileProvider. The AppliesTo attribute on that MEF export means that the project must have the RoslynComponent ProjectCapability, however Riok.Mapperly doesn't appear to. Explicitly adding the capability fixes the issue, but that shouldn't be necessary.

Roslyn's Microsoft.Managed.Core.targets attempts to add the capability here in Microsoft.Managed.Core.targets, so that must not be part of evaluation (or is being overridden). I have some binlogs, but have a question for a colleague before continuing investigation.

I don't think this problem is specific to the Riok.Mapperly project/solution. I checked one of my own source generators, and that project also doesn't have the RoslynComponent project capability. I suspect something has changed in how we load targets for design-time builds.

@drewnoakes
Copy link
Member

I don't think this problem is specific to the Riok.Mapperly project/solution. I checked one of my own source generators, and that project also doesn't have the RoslynComponent project capability. I suspect something has changed in how we load targets for design-time builds.

I was misunderstanding what I was seeing in the logs. Looking again today with fresh eyes, I see the problem,

Projects that contain source generators and/or analyzers (such as src/Riok.Mapperly/Riok.Mapperly.csproj) must specify the IsRoslynComponent property as true. i.e.:

<PropertyGroup>
  <IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>

So I don't think there's a "bug" here. I'm not sure offhand how we could improve the experience though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Debugging Launching an application via F5, setting debug properties and launch profiles. Triage-Approved Reviewed and prioritized
Projects
None yet
Development

No branches or pull requests

3 participants