From 98156ca7f52444b6e58dbcbc5f4960cdcb9221a1 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Mon, 17 Nov 2025 16:20:38 +0800 Subject: [PATCH 1/3] update System.CommandLine usage and mention env dotnet shebang config --- .../fundamentals/tutorials/file-based-programs.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/csharp/fundamentals/tutorials/file-based-programs.md b/docs/csharp/fundamentals/tutorials/file-based-programs.md index 0f0c8bcba8dad..c1b3466a2df1b 100644 --- a/docs/csharp/fundamentals/tutorials/file-based-programs.md +++ b/docs/csharp/fundamentals/tutorials/file-based-programs.md @@ -84,7 +84,13 @@ On unix, you can run file-based apps directly, typing the source file name on th #!/usr/local/share/dotnet/dotnet run ``` -The location of `dotnet` can be different on different unix installations. Use the command `whence dotnet` to local the `dotnet` host in your environment. +The location of `dotnet` can be different on different unix installations. Use the command `where dotnet` to local the `dotnet` host in your environment. + +Or you can use to resolve dotnet path by the PATH environment automatically + +```csharp +#!/usr/bin/env dotnet +``` After making these two changes, you can run the program from the command line directly: @@ -211,7 +217,7 @@ The `System.CommandLine` library offers several key benefits: :::code language="csharp" source="./snippets/file-based-programs/AsciiArt.cs" id="CommandLinePackage"::: > [!IMPORTANT] - > The version `2.0.0-beta6` was the latest version when this tutorial was last updated. If there's a newer version available, use the latest version to ensure you have the latest security packages. Check the package's [NuGet page](https://www.nuget.org/packages/System.CommandLine) for the latest version to ensure you use a package version with the latest security fixes. + > The version `2.0.0` was the latest version when this tutorial was last updated. If there's a newer version available, use the latest version to ensure you have the latest security packages. Check the package's [NuGet page](https://www.nuget.org/packages/System.CommandLine) for the latest version to ensure you use a package version with the latest security fixes. 1. Add the necessary using statements at the top of your file (after the `#!` and `#:package` directives): From 060d9413fa3303940624367cbb64aa3e14434d4c Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Mon, 17 Nov 2025 16:23:15 +0800 Subject: [PATCH 2/3] update file-based-programs.md --- docs/csharp/fundamentals/tutorials/file-based-programs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/fundamentals/tutorials/file-based-programs.md b/docs/csharp/fundamentals/tutorials/file-based-programs.md index c1b3466a2df1b..8f4f47cba3a80 100644 --- a/docs/csharp/fundamentals/tutorials/file-based-programs.md +++ b/docs/csharp/fundamentals/tutorials/file-based-programs.md @@ -86,7 +86,7 @@ On unix, you can run file-based apps directly, typing the source file name on th The location of `dotnet` can be different on different unix installations. Use the command `where dotnet` to local the `dotnet` host in your environment. -Or you can use to resolve dotnet path by the PATH environment automatically +Or you can use the following way to resolve the dotnet path by the PATH environment automatically ```csharp #!/usr/bin/env dotnet From fcfcf729faad8c79d3f4ce859c070d16ab2d3655 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Mon, 17 Nov 2025 17:07:54 +0800 Subject: [PATCH 3/3] apply copilot suggestions --- docs/csharp/fundamentals/tutorials/file-based-programs.md | 4 ++-- .../tutorials/snippets/file-based-programs/AsciiArt | 2 +- .../tutorials/snippets/file-based-programs/AsciiArt.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/csharp/fundamentals/tutorials/file-based-programs.md b/docs/csharp/fundamentals/tutorials/file-based-programs.md index 8f4f47cba3a80..e3357a630eec7 100644 --- a/docs/csharp/fundamentals/tutorials/file-based-programs.md +++ b/docs/csharp/fundamentals/tutorials/file-based-programs.md @@ -84,9 +84,9 @@ On unix, you can run file-based apps directly, typing the source file name on th #!/usr/local/share/dotnet/dotnet run ``` -The location of `dotnet` can be different on different unix installations. Use the command `where dotnet` to local the `dotnet` host in your environment. +The location of `dotnet` can be different on different unix installations. Use the command `which dotnet` to locate the `dotnet` host in your environment. -Or you can use the following way to resolve the dotnet path by the PATH environment automatically +Alternatively, you can use #!/usr/bin/env dotnet to resolve the dotnet path from the PATH environment variable automatically: ```csharp #!/usr/bin/env dotnet diff --git a/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt b/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt index 78bb5e08a7b4c..1467798177dff 100755 --- a/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt +++ b/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt @@ -1,7 +1,7 @@ #!/usr/local/share/dotnet/dotnet run #:package Colorful.Console@1.2.15 -#:package System.CommandLine@2.0.0-beta6 +#:package System.CommandLine@2.0.0 using System.CommandLine; using System.CommandLine.Parsing; diff --git a/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt.cs b/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt.cs index 24ba5db893246..761dafc2ebb9a 100755 --- a/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt.cs +++ b/docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt.cs @@ -4,7 +4,7 @@ #:package Colorful.Console@1.2.15 // // -#:package System.CommandLine@2.0.0-beta6 +#:package System.CommandLine@2.0.0 // //