rogerfar / rdt-client

Real-Debrid Client Proxy
MIT License
853 stars 110 forks source link

App looks for appsettings.json in CWD instead of in location where exe is located #495

Open Masamune3210 opened 4 months ago

Masamune3210 commented 4 months ago

What version are you using? 2.0.77.0 What OS are you running? (Btw, Typo here, Wat instead of What) Windows 11 Are you using Docker or as a service? No, manually launched through terminal Which debrid provider are you using? N/A Which downloader are you using? N/A Please attach a log file here with the log setting set to debug Unhandled exception. System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The expected physical path was 'C:\Users\User\appsettings.json'. at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.ConfigurationManager.AddSource(IConfigurationSource source) at Microsoft.Extensions.Configuration.ConfigurationManager.Microsoft.Extensions.Configuration.IConfigurationBuilder.Add(IConfigurationSource source) at Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder builder, String path, Boolean optional, Boolean reloadOnChange) at Program.<Main>$(String[] args) in C:\Projects\rdt-client\server\RdtClient.Web\Program.cs:line 20

rogerfar commented 4 months ago

That's pretty common if you haven't specified your working directory correctly. How are you starting the app?

Masamune3210 commented 4 months ago

by having the program directory in the system path and executing RdtClient.Web.exe from a terminal window

rogerfar commented 4 weeks ago

I have never seen this behaviour yet, what .NET runtime are you using? And where is rdt-client extracted to?

And what command are you using to start the app?

Masamune3210 commented 3 weeks ago

Just the normal one that you would get from Microsoft, if you need any more verbosity on that point you will have to let me know how to give it

.\rdtclient.web.exe

rogerfar commented 3 weeks ago

And just to be sure, the appsettings.json file is in the same folder right?

Masamune3210 commented 3 weeks ago

Yep, executing .\rdtclient.web.exe in the folder where the exe resides alongside its other files works fine, but just executing rdtclient.web.exe outside of the folder attempts to look for the json in the cwd instead of the directory the executable is in, saying

Unhandled exception. System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The expected physical path was 'G:\Users\User\Downloads\appsettings.json'. at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.ConfigurationManager.AddSource(IConfigurationSource source) at Microsoft.Extensions.Configuration.ConfigurationManager.Microsoft.Extensions.Configuration.IConfigurationBuilder.Add(IConfigurationSource source) at Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder builder, String path, Boolean optional, Boolean reloadOnChange) at Program.

$(String[] args) in C:\Projects\rdt-client\server\RdtClient.Web\Program.cs:line 21

Masamune3210 commented 3 weeks ago

Could it possibly be from this line? It seems to be adding the json but not specifying a directory before it, which if I'm not mistaken, causes it to look for the folder in the working directory

image