Create a .NET App With GitHub Actions

This blog post will show you how to create a .NET console application in C# with GitHub Actions.

GitHub Actions allow us to run .NET code applications on Linunx or Windows runners since both of them are capable of running .NET 5.

Workflow

In the below workflow, I am creating a simple console application using C#.

The application will use the latest .NET 5 version that is available on GitHub Actions runner. I can also create an artifact from the code, as we learn in the previous post on the topic.

name: Create a .NET app

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 5.0.x
    - name: Create a new console app
      run: dotnet new console -o myApp
    - name: Run app
      run: | 
       cd myApp
       dotnet run

Posted

in

by