-
Notifications
You must be signed in to change notification settings - Fork 802
Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
When using the Aspire.Hosting.NodeJs library we should be able to debug nodejs apps
Describe the solution you'd like
have https://github.com/dotnet/aspire/blob/main/src/Aspire.Hosting.NodeJs/NodeExtensions.cs call the WithVSCodeDebugSupport method on the builder (probaby with null for requiredExtensionId since nodejs is built-in)
Additional context
something like this:
public static IResourceBuilder<NodeAppResource> AddNodeApp(this IDistributedApplicationBuilder builder, [ResourceName] string name, string scriptPath, string? workingDirectory = null, string[]? args = null)
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentException.ThrowIfNullOrEmpty(name);
ArgumentException.ThrowIfNullOrEmpty(scriptPath);
args ??= [];
string[] effectiveArgs = [scriptPath, .. args];
workingDirectory ??= Path.GetDirectoryName(scriptPath)!;
workingDirectory = PathNormalizer.NormalizePathForCurrentPlatform(Path.Combine(builder.AppHostDirectory, workingDirectory));
var resource = new NodeAppResource(name, "node", workingDirectory);
var resourceBuilder = builder.AddResource(resource)
.WithNodeDefaults()
.WithArgs(effectiveArgs);
- return builder.AddResource(resource)
+ // Add VS Code debug support
+ return resourceBuilder.WithVSCodeDebugSupport(Path.Join(workingDirectory, scriptPath),
+ "node", // Debug adapter ID
+ null, // built-in extension
+ ctx => ctx.Args.RemoveAt(0); // The first argument when running from command line is the entrypoint file
+ );
}similar to this
aspire/src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs
Lines 151 to 154 in d9077f9
| resourceBuilder.WithVSCodeDebugSupport(Path.Join(appDirectory, scriptPath), "python", "ms-python.python", ctx => | |
| { | |
| ctx.Args.RemoveAt(0); // The first argument when running from command line is the entrypoint file. | |
| }); |
FYI @adamint
Reactions are currently unavailable