Open IanKemp opened 1 month ago
@IanKemp Do you have the ".NET Compiler Platform SDK" component installed in Visual Studio?
I assume Ian worked this out based on https://github.com/dotnet/project-system/issues/9011#issuecomment-2395055168.
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 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.
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'.
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.
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.
@drewnoakes you are my hero of the day! 🙂↕️
Visual Studio Version
2022.17.11.4 (Community edition)
Summary
As title.
Suspect that the work done in https://github.com/dotnet/roslyn-sdk/pull/896 for https://github.com/dotnet/roslyn-sdk/issues/850 has either been reverted or broken.
Steps to Reproduce
Creating a new "Roslyn Component" launch profile is also not possible, as that option is missing from the "Launch Profiles" UI
Expected Behavior
Source generator debugging works
Actual Behavior
Source generator debugging does not work
User Impact
Can't debug source generators