roslyn: Can't debug source generator using roslyn component if total dependency file path lengths is too big
Here is a repo with steps to reproduce the problem: https://github.com/KieranDevvs/SourceGeneratorBugSample/tree/master
I also encounter this when referencing non nuget packages i.e David Fowlers Bedrock.Framework
package. (I can’t confirm this as it is the only package that I have used that is not in a nuget.org feed thus the problem may be related to something else).
This is using the 5.0.400
SDK in VS2019 version 16.11.1 (also described within the repo readme).
Steps to reproduce:
- Install the .NET compiler platform SDK (described in this post: http://stevetalkscode.co.uk/debug-source-generators-with-vs2019-1610)
- Clone the repository and open it in visual studio 2019 version 16.11.1.
- Build the solution and find no build errors.
- Set the
SourceGenerator
project to be the startup project. - Debug the project.
- See error:
- Open the
SomeLibrary
csproj file and remove<FrameworkReference Include="Microsoft.AspNetCore.App" />
. - Debug the project again, this time no error will show and the project will successfully execute with the debugger attached.
This also appears to occour with dependencies that arent in nuget.org (I cant confirm this easily as I have only used one dependency that did not come from nuget.org thus, this may just be a coincidence).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 12
- Comments: 21 (7 by maintainers)
Commits related to this issue
- Removed workaround for https://github.com/dotnet/roslyn/issues/55802. The bug has been fixed in VS 2022 v17.2. — committed to json-api-dotnet/JsonApiDotNetCore by bkoelman 2 years ago
- Removed workaround for debugging source generators (#1155) * Removed workaround for https://github.com/dotnet/roslyn/issues/55802. The bug has been fixed in VS 2022 v17.2. * Package updates (in no... — committed to json-api-dotnet/JsonApiDotNetCore by bkoelman 2 years ago
- Removed workaround for debugging source generators (#1155) * Removed workaround for https://github.com/dotnet/roslyn/issues/55802. The bug has been fixed in VS 2022 v17.2. * Package updates (in no... — committed to nicolestandifer3/DotNet-Core-Json-Api by nicolestandifer3 2 years ago
I just tried using this feature after upgrading to 17.1 Preview 2 and seeing the same issue. Is it still planned on making it into 17.1?
@KieranDevvs Hmm, I thought it made it in, but i’ll double check and get back to you.
For all that are still waiting on this, it looks to be fixed in the latest 17.2 update released a few hours ago.
Its not in 17.2 Preview 1 either 😦
I’m experiencing the same limitation, using both VS 2019 and VS 2022. I didn’t see anything in ProcMon that relates to this error, so it seems CreateProcess is never even called. Based on my experiments, it seems source generators can only be debugged in extremely simple projects without real-life dependencies such as ASP.NET and third-party libraries.
Please prioritize to fix this, because source generators are quite useless for production this way. The momentum is now, if you’re going to hold off a fix for another six months, nobody cares anymore and we’ve already chosen a competing solution without source generators.