Skip to content

Create main.yml

Create main.yml #3

Workflow file for this run

name: .NET Build
# For more information on this YAML file, please reference blog: https://agramont.net/blog/devops-intro-deploy-net-aspire-azure-github-actions
on:
workflow_dispatch:
push:
# Run when commits are pushed to mainline branch (main or master)
# Set this to the mainline branch you are using
branches:
- master
- main
pull_request:
branches: [ "dev", "master", "main" ]
# Based from https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-net
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup dotnet 9.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install .NET Aspire workload
run: dotnet workload install aspire
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build
- name: Test with the dotnet CLI
run: dotnet test --logger trx --results-directory TestResults
- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: dotnet-test-results
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}