dotnet-rex
0.0.0-alpha.4
dotnet tool install --global dotnet-rex --version 0.0.0-alpha.4
dotnet new tool-manifest
dotnet tool install --local dotnet-rex --version 0.0.0-alpha.4
#tool dotnet:?package=dotnet-rex&version=0.0.0-alpha.4&prerelease
nuke :add-package dotnet-rex --version 0.0.0-alpha.4
dotnet-rex
This is a cli tool that can run projects or files that leverage Hyprx.Rex.Console.
DotNet 10 or higher must be installed locally to use rex.
The cli tool has help support with --help flag.
Rexfile
The dotnet-rex cli will look in the current working directory and look for a file called "rexfile" with no extension. This file is a configuration file for telling rex where to look for the file or csproj that contains tasks.
The rexfile setting within the file will tell dotnet-rex where to find either the csproj file, the single csharp file, or the assembly to run.
If the file is not found, dotnet-rex will look for a rexfile.cs in the current folder or look for a subfolder called .dotnet-rex and then load a file called ./.rex/main.cs or the first csproj it finds in the .dotnet-rex folder: ./.rex/*.csproj.
Using the dotnet-rex file is the most explicit.
Using a project
rexfile:./RexKitchen/RexKitchen.csproj
Using a file
rexfile:./path/to/rexfile.cs
rexfile:./path/to/app.cs
Using an assembly
rexfile:./path/to/app.dll
List tasks/jobs
dotnet-rex list
list namespaces will show all namespaces that are defined.
dotnet-rex list namespaces
list services will shall all namespaces that are defined as a service.
dotnet-rex list services
Run a task
# runs a job or task called hello
dotnet-rex hello
# runs a job or task called hello
dotnet-rex target hello
This is the most explicit.
# runs only a task called hello.
dotnet-rex tasks run hello
Run many tasks
dotnet-rex target many "target1" "target2"
dotnet-rex tasks "task1" "task2"
This is the most explicit.
dotnet-rex tasks run many "task1" "task2"
Note, if the task has the same name as a job or deployment, you'll need use the tasks subcommand so that dotnet-rex knows which one to use.
Run a job
Runs a single job and any dependencies.
# runs a job or task alled job1
dotnet-rex job1
# runs a job or task alled job1
dotnet-rex target job1
dotnet-rex jobs run job1
Run many jobs
dotnet-rex target many "job1" "job2"
dotnet-rex jobs "job1" "job2"
this is the most explicit
dotnet-rex jobs run many "job1" "job2"
Alias Commands
- build
- clean
- test
- restore
- pack
- publish
- up
- down
- rollback
These are shortcuts to running a job or task with the same name. A command like
dotnet-rex build is a shortcut to calling dotnet-rex run build
. If a job is found the job
will be used and if a job doesn't an exist, but a task does, then the task called
build will be used.
These shortcut tasks also have an additional service
argument.
When the service argument is used and the service
argument value does not start with hyphen and the target does not contain a colon (:), the service
binds the target to a namespace.
So if you define a task called mysql:up you can run
dotnet-rex up mysql
or you can run
dotnet-rex mysql:up
so if you want to pass an argument in and not have it picked up as a service argument, you must be explicit or prefix a task with colon (:).
dotnet-rex mysql:up arg1
dotnet-rex :up arg1
Options
- --context - The context is useful for switching between contexts in a task. e.g. local vs ci.
- --verbose - Logs additional verbose information.
- --env - Sets an environment variable. Can be used many times.
- --env-file - Sets a dotenv file. This file is loaded for the given task or job.
- --secrets-file - Sets a dotenv file. This file is treated as a file of secrets and is loaded for the given task or job. (Secrets are added to the SecretMasker which can be used to scrub output).
- --timeout - Sets the timeout for the job or task. If the execution takes too long, the job or task will be cancelled.
- --file - Sets the rexfile or csproj file that you want to use rather than looking in the current directory.
Defining tasks
You'll need to have project or single csharp file that has a package reference to Hyprx.Rex.Console.
#pragma warning disable SA1117, SA1500, SA1116
using Hyprx;
using static Hyprx.RexConsole;
using static Hyprx.Shell;
Task("default", () => Echo("Hello, World!"));
Task("hello", () => Echo("Hello from RexKitchen!"));
Task("env", () => Echo(Env.Expand("$MY_VALUE")));
Task("build", () => Echo("Building..."));
Task("inspect", (ctx) =>
{
Echo($"Context: {ctx.Name}");
Echo($"Task: {ctx.Data.Id}");
Echo($"Env: {string.Join(", ", ctx.Env)}");
Echo($"Needs: {string.Join(", ", ctx.Data.Needs)}");
Echo($"Args: {string.Join(", ", ctx.Args)}");
})
.WithNeeds(["hello"]);
Job("job1", (job) =>
{
// addes the global task "hello" as a dependency to all tasks in this job
// which allows you to share common tasks across multiple job
// and run them as a standalone task as well.
job.AddGlobalTask("hello");
job.Task("task1", () => Echo("Task 1"));
job.Task("task2", () => Echo("Task 2"));
});
// use namespace will create a job or task with the given namespace.
// task up becomes mssql:up
// task down becomes mssql:down
//
// when true is set, the namespace is created like a service or project.
// so you can call
// `dotnet-rex up mssql` or `dotnet-rex run mssql:up`
//
// the concept of service is to make it easier to target a specific project
// service, or subfolder.
UseNamespace("mssql", true, () =>
{
Task("up", () => Echo("Hello from MSSQL!"));
Task("down", () => Echo("Goodbye from MSSQL!"));
});
return await RunTasksAsync(args);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
Version | Downloads | Last Updated |
---|---|---|
0.0.0-alpha.4 | 103 | 7/11/2025 |
0.0.0-alpha.2 | 120 | 6/25/2025 |
0.0.0-alpha.1 | 114 | 6/25/2025 |
0.0.0-alpha.0 | 121 | 6/17/2025 |