Non-ASP.NET apps - default project path #598

Closed
opened 2025-08-09 17:16:54 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @coosmiin on 7/10/2017

When trying to use the services in a non-ASP.NET app, I had to set the ProjectPath option to current directory in order to make it work:

var services = new ServiceCollection();
services.AddNodeServices(options => {
	options.ProjectPath = Directory.GetCurrentDirectory();
});
IServiceProvider serviceProvider = services.BuildServiceProvider();
var nodeServices = serviceProvider.GetRequiredService<INodeServices>();
var result = await nodeServices.InvokeAsync<int>("addNumbers", 1, 2);

I would expect the ProjectPath to be set by default to current directory, or, at least to make it clear in the documentation that you need to specify the ProjectPath correctly.

*Originally created by @coosmiin on 7/10/2017* When trying to use the services in a non-ASP.NET app, I had to set the `ProjectPath` option to current directory in order to make it work: ```csharp var services = new ServiceCollection(); services.AddNodeServices(options => { options.ProjectPath = Directory.GetCurrentDirectory(); }); IServiceProvider serviceProvider = services.BuildServiceProvider(); var nodeServices = serviceProvider.GetRequiredService<INodeServices>(); var result = await nodeServices.InvokeAsync<int>("addNumbers", 1, 2); ``` I would expect the `ProjectPath` to be set by default to current directory, or, at least to make it clear in the documentation that you need to specify the ProjectPath correctly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#598
No description provided.