This guide will walk you through building an example job from scratch. It will teach you how to:
- Build the Host Application (this page)
- Build the job
- Run and Debug your job locally
Create the Host Application
Runly jobs are hosted in a console application that builds and runs Runly.JobHost in its Main method. There are several benefits to executing jobs this way:
- Run from the command line or IDE without any special considerations
- Debug using the same tools as any other console application
- Manage dependencies in the project
There are a few ways to bootstrap a Runly job app.
GitHub Template
You can create a new job app with one click from the GitHub template. This will create a new repository for you that you can clone and immediately start running a job.
dotnet Template
Skip the Git repo and create a local app via the dotnet new template:
Install the
Runly.Templatespackage.dotnet new -i Runly.TemplatesCreate a directory for the project then use the
runly-apptemplate to create a new project:mkdir myproject cd myproject dotnet new runly-app
This will create a console application using the JobHost to bootstrap the application.
Do it Manually
If you’d rather not install/use the Runly app template, you can create jobs using a generic console app.
Create a new .Net Core console app:
mkdir myproject cd myproject dotnet new consoleInstall the Runly nuget package in your project.
dotnet add package RunlyIn
Program.cs, replace theMainmethod with the following:static Task Main(string[] args) { return JobHost.CreateDefaultBuilder(args) .Build() .RunJobAsync(); }Add a reference to the
Runlynamespace soJobHostresolves:using Runly;Be sure to set the
csprojto pack as a tool so that Runly can run your app if you decide to upload it to the Runly Platform:<PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> <PackAsTool>true</PackAsTool> </PropertyGroup>
Run the Application
You can run the application now using your IDE or via the command line:
dotnet run -- helpThis will show you available commands that the Runly JobHost gives you for free.
Congratulations! You have now built the host application that will run your jobs.
Continue to Step 2: Build the Job >>