Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
If dotnet user-jwts create
is run from a current directory other than the project directory (e.g. accidentally running it at the repo root instead of the child folder containing a web application) then an unhandled exception is thrown and printed to the console.
❯ dotnet user-jwts create
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.ArgumentNullException.Throw(String paramName)
at System.IO.Path.Combine(String path1, String path2, String path3)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.DevJwtCliHelpers.GetAudienceCandidatesFromLaunchSettings(String project)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.CreateCommand.ValidateArguments(IReporter reporter, CommandOption projectOption, CommandOption schemeNameOption, CommandOption nameOption, CommandOption audienceOption, CommandOption issuerOption, CommandOption notBeforeOption, CommandOption expiresOnOption, CommandOption validForOption, CommandOption rolesOption, CommandOption scopesOption, CommandOption claimsOption)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.CreateCommand.<>c__DisplayClass2_0.<Register>b__1()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.Program.Run(String[] args)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.Program.Main(String[] args)
Expected Behavior
A user-friendly error message is shown, perhaps indicating that an expected file cannot be found, which guides the user as to their mistake.
Steps To Reproduce
The exception can be readily reproduced by running the command at the root of a drive.
cd c:/
dotnet user-jwts create
Exceptions (if any)
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.ArgumentNullException.Throw(String paramName)
at System.IO.Path.Combine(String path1, String path2, String path3)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.DevJwtCliHelpers.GetAudienceCandidatesFromLaunchSettings(String project)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.CreateCommand.ValidateArguments(IReporter reporter, CommandOption projectOption, CommandOption schemeNameOption, CommandOption nameOption, CommandOption audienceOption, CommandOption issuerOption, CommandOption notBeforeOption, CommandOption expiresOnOption, CommandOption validForOption, CommandOption rolesOption, CommandOption scopesOption, CommandOption claimsOption)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.CreateCommand.<>c__DisplayClass2_0.<Register>b__1()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.Program.Run(String[] args)
at Microsoft.AspNetCore.Authentication.JwtBearer.Tools.Program.Main(String[] args)
.NET Version
7.0.100-preview.5.22307.18
Anything else?
No response