|
| 1 | +# Justfile .NET - Benjamin Abt 2025 - https://benjamin-abt.com |
| 2 | +# https://github.com/BenjaminAbt/templates/blob/main/justfile/dotnet |
| 3 | + |
| 4 | +set shell := ["pwsh", "-c"] |
| 5 | + |
| 6 | +# ===== Configurable defaults ===== |
| 7 | +CONFIG := "Debug" |
| 8 | +TFM := "net10.0" |
| 9 | +BENCH_PRJ := "perf/HttpUserAgentParser.Benchmarks/HttpUserAgentParser.Benchmarks.csproj" |
| 10 | + |
| 11 | +# ===== Default / Help ===== |
| 12 | +default: help |
| 13 | + |
| 14 | +help: |
| 15 | + # Overview: |
| 16 | + just --list |
| 17 | + # Usage: |
| 18 | + # just build |
| 19 | + # just test |
| 20 | + # just bench |
| 21 | + |
| 22 | +# ===== Basic .NET Workflows ===== |
| 23 | +restore: |
| 24 | + dotnet restore |
| 25 | + |
| 26 | +build *ARGS: |
| 27 | + dotnet build --configuration "{{CONFIG}}" --nologo --verbosity minimal {{ARGS}} |
| 28 | + |
| 29 | +rebuild *ARGS: |
| 30 | + dotnet build --configuration "{{CONFIG}}" --nologo --verbosity minimal --no-incremental {{ARGS}} |
| 31 | + |
| 32 | +clean: |
| 33 | + dotnet clean --configuration "{{CONFIG}}" --nologo |
| 34 | + |
| 35 | +run *ARGS: |
| 36 | + dotnet run --project --framework "{{TFM}}" --configuration "{{CONFIG}}" --no-launch-profile {{ARGS}} |
| 37 | + |
| 38 | +# ===== Quality / Tests ===== |
| 39 | +format: |
| 40 | + dotnet format --verbosity minimal |
| 41 | + |
| 42 | +format-check: |
| 43 | + dotnet format --verify-no-changes --verbosity minimal |
| 44 | + |
| 45 | +test *ARGS: |
| 46 | + dotnet test --configuration "{{CONFIG}}" --framework "{{TFM}}" --nologo --verbosity minimal {{ARGS}} |
| 47 | + |
| 48 | +test-cov: |
| 49 | + dotnet test --configuration "{{CONFIG}}" --framework "{{TFM}}" --nologo --verbosity minimal /p:CollectCoverage=true /p:CoverletOutputFormat="cobertura,lcov,opencover" /p:CoverletOutput="./TestResults/coverage/coverage" |
| 50 | + |
| 51 | + |
| 52 | +test-filter QUERY: |
| 53 | + dotnet test --configuration "{{CONFIG}}" --framework "{{TFM}}" --nologo --verbosity minimal --filter "{{QUERY}}" |
| 54 | + |
| 55 | +# ===== Packaging / Release ===== |
| 56 | +pack *ARGS: |
| 57 | + dotnet pack --configuration "{{CONFIG}}" --nologo --verbosity minimal -o "./artifacts/packages" {{ARGS}} |
| 58 | + |
| 59 | +publish *ARGS: |
| 60 | + dotnet publish --configuration "{{CONFIG}}" --framework "{{TFM}}" --nologo --verbosity minimal -o "./artifacts/publish/{{TFM}}" {{ARGS}} |
| 61 | + |
| 62 | +publish-sc RID *ARGS: |
| 63 | + dotnet publish --configuration "{{CONFIG}}" --framework "{{TFM}}" --runtime "{{RID}}" --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false --nologo --verbosity minimal -o "./artifacts/publish/{{TFM}}-{{RID}}" {{ARGS}} |
| 64 | + |
| 65 | +# ===== Benchmarks ===== |
| 66 | +bench *ARGS: |
| 67 | + dotnet run --configuration Release --project "{{BENCH_PRJ}}" --framework "{{TFM}}" {{ARGS}} |
| 68 | + |
| 69 | +# ===== Housekeeping ===== |
| 70 | +clean-artifacts: |
| 71 | + if (Test-Path "./artifacts") { Remove-Item "./artifacts" -Recurse -Force } |
| 72 | + |
| 73 | +clean-all: |
| 74 | + just clean |
| 75 | + just clean-artifacts |
| 76 | + # Optionally: git clean -xdf |
| 77 | + |
| 78 | +# ===== Combined Flows ===== |
| 79 | +fmt-build: |
| 80 | + just format |
| 81 | + just build |
| 82 | + |
| 83 | +ci: |
| 84 | + just clean |
| 85 | + just restore |
| 86 | + just format-check |
| 87 | + just build |
| 88 | + just test-cov |
0 commit comments