This guide will walk you through building an example job from scratch. It will teach you how to:

  1. Build the Host Application (this page)
  2. Build the job
  3. 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:

  1. Install the Runly.Templates package.

    dotnet new -i Runly.Templates
  2. Create a directory for the project then use the runly-app template 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.

  1. Create a new .Net Core console app:

    mkdir myproject
    cd myproject
    dotnet new console
  2. Install the Runly nuget package in your project.

    dotnet add package Runly
  3. In Program.cs, replace the Main method with the following:

    static Task Main(string[] args)
    {
    	return JobHost.CreateDefaultBuilder(args)
    		.Build()
    		.RunJobAsync();
    }
  4. Add a reference to the Runly namespace so JobHost resolves:

    using Runly;
  5. Be sure to set the csproj to 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 -- help

This 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 >>