Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dotnet run example in System.CommandLine tutorial #40757

Closed
vernou opened this issue May 4, 2024 · 4 comments · Fixed by #41823
Closed

Fix dotnet run example in System.CommandLine tutorial #40757

vernou opened this issue May 4, 2024 · 4 comments · Fixed by #41823
Assignees
Labels
doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-fundamentals/svc okr-health okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@vernou
Copy link
Contributor

vernou commented May 4, 2024

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

Associated WorkItem - 287048

@issues-automation issues-automation bot added dotnet-fundamentals/svc Pri1 High priority, do before Pri2 and Pri3 labels May 4, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label May 4, 2024
@vernou
Copy link
Contributor Author

vernou commented May 4, 2024

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.

@vernou
Copy link
Contributor Author

vernou commented May 15, 2024

Similar to dotnet/command-line-api#2427.

@tdykstra tdykstra added the doc-bug Problem with the content; needs to be fixed [org][type][category] label May 28, 2024
@tdykstra tdykstra self-assigned this May 28, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label May 28, 2024
@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label May 28, 2024
@tdykstra
Copy link
Contributor

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.

@vernou
Copy link
Contributor Author

vernou commented Jul 18, 2024

@tdykstra

Indeed, nice catch.


I did the PR #41823.

@tdykstra tdykstra changed the title dotnet run example don't work Fix dotnet run example in System.CommandLine tutorial Jul 19, 2024
@tdykstra tdykstra added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Jul 19, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-fundamentals/svc okr-health okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants