dotnet run example don't work
Type of issue
Code doesn't work
Description
In the chapter Test the app, it say you can test the app with the command dotnet run -- --file scl.runtimeconfig.json executed from a shell in the project directory.
But with dotnet run, the working directory is the project directory, so the file scl.runtimeconfig.json isn't found and the execution fail.
The working command is :
dotnet run -- --file bin/Debug/net6.0/scl.runtimeconfig.json/scl.runtimeconfig.json
I suggest to modify the command and add a short explanation why this path. If you agree, I can do the PR.
Page URL
https://learn.microsoft.com/en-us/dotnet/standard/commandline/get-started-tutorial
Content source URL
https://github.com/dotnet/docs/blob/main/docs/standard/commandline/get-started-tutorial.md
Document Version Independent Id
fa160b1d-66ed-8c5d-37cd-b7e02443e9f1
Article author
@tdykstra
Metadata
- ID: 7705dc41-7297-0807-7e9c-2e6548c26b84
- Service: dotnet-fundamentals
Also, the doc present incoherent return for Main.Program :
// First example
class Program
{
static async Task<int> Main(string[] args)
{
...
return await rootCommand.InvokeAsync(args);
}
}
// Second example
class Program
{
static async Task<int> Main(string[] args)
{
...
return rootCommand.InvokeAsync(args).Result;
}
}
The second compile with a warning, I presume the first is the correct.
Similar to dotnet/command-line-api#2427.
Hello @vernou. Thank you for contacting us. You are right that there is a problem with that run command, but your proposed replacement won't work because:
dotnet run -- --file bin/Debug/net6.0/scl.runtimeconfig.json/scl.runtimeconfig.json
assumes there is as folder named scl.runtimeconfig.json. The correct command is:
dotnet run -- --file bin/Debug/net6.0/scl.runtimeconfig.json
You're also correct about the return await ... being the right form.
If you would still like to submit a pull request that would be welcome.
@tdykstra
Indeed, nice catch.
I did the PR #41823.