Skip to content

Commit fd29c25

Browse files
authored
file-based program document enhancement (#49928)
* update System.CommandLine usage and mention env dotnet shebang config * update file-based-programs.md * apply copilot suggestions
1 parent 7ee7062 commit fd29c25

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

docs/csharp/fundamentals/tutorials/file-based-programs.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ On unix, you can run file-based apps directly, typing the source file name on th
8484
#!/usr/local/share/dotnet/dotnet run
8585
```
8686

87-
The location of `dotnet` can be different on different unix installations. Use the command `whence dotnet` to local the `dotnet` host in your environment.
87+
The location of `dotnet` can be different on different unix installations. Use the command `which dotnet` to locate the `dotnet` host in your environment.
88+
89+
Alternatively, you can use #!/usr/bin/env dotnet to resolve the dotnet path from the PATH environment variable automatically:
90+
91+
```csharp
92+
#!/usr/bin/env dotnet
93+
```
8894

8995
After making these two changes, you can run the program from the command line directly:
9096

@@ -211,7 +217,7 @@ The `System.CommandLine` library offers several key benefits:
211217
:::code language="csharp" source="./snippets/file-based-programs/AsciiArt.cs" id="CommandLinePackage":::
212218

213219
> [!IMPORTANT]
214-
> 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.
220+
> 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.
215221
216222
1. Add the necessary using statements at the top of your file (after the `#!` and `#:package` directives):
217223

docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/local/share/dotnet/dotnet run
22

33
#:package Colorful.Console@1.2.15
4-
#:package System.CommandLine@2.0.0-beta6
4+
#:package System.CommandLine@2.0.0
55

66
using System.CommandLine;
77
using System.CommandLine.Parsing;

docs/csharp/fundamentals/tutorials/snippets/file-based-programs/AsciiArt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#:package Colorful.Console@1.2.15
55
// </ColorfulPackage>
66
// <CommandLinePackage>
7-
#:package System.CommandLine@2.0.0-beta6
7+
#:package System.CommandLine@2.0.0
88
// </CommandLinePackage>
99

1010
// <Usings>

0 commit comments

Comments
 (0)