A dotnet tool to list and run examples similar to Rust's cargo run --example
.
> dotnet tool install -g dotnet-example
> dotnet example
> dotnet example hello
Hello World!
> dotnet example hello --source
The convention is simple, if there is an examples
or samples
folder
in the directory the tool is executed in, it will fetch all csproj files
and find the best match to the query.
If examples are located in unconventional folders, add a .examples
file
with the (relative) paths of the examples folders, one per line. Blank lines
or lines starting with #
in the .examples
file are ignored.
To change the name, description, and the order of an example, edit it's csproj
file, and add the following section:
<PropertyGroup>
<ExampleTitle>Foo</ExampleTitle>
<ExampleDescription>This is the description of the example.</ExampleDescription>
<ExampleOrder>5</ExampleOrder>
</PropertyGroup>
If no name is set in the csproj
file, the project name will be used.