Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/csharp/fundamentals/tutorials/file-based-programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `which dotnet` to locate the `dotnet` host in your environment.

Alternatively, you can use #!/usr/bin/env dotnet to resolve the dotnet path from the PATH environment variable automatically:

```csharp
#!/usr/bin/env dotnet
```

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

Expand Down Expand Up @@ -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):

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#:package Colorful.Console@1.2.15
// </ColorfulPackage>
// <CommandLinePackage>
#:package System.CommandLine@2.0.0-beta6
#:package System.CommandLine@2.0.0
// </CommandLinePackage>

// <Usings>
Expand Down