Skip to content

Instantly share code, notes, and snippets.

@FilBot3
Created October 13, 2022 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FilBot3/1e77f40bbe7fd9968091ecd542c9c301 to your computer and use it in GitHub Desktop.
Save FilBot3/1e77f40bbe7fd9968091ecd542c9c301 to your computer and use it in GitHub Desktop.
A Taskfile for .NET Core setup of new projects automating some of it for others. Doesn't cover EVERY option or idea, but it should be fairly easy to extend.
---
# https://taskfile.dev
version: '3'
vars:
PROJ: HelloWorld
tasks:
default:
desc: Default task(s)
deps:
- build
new-console:
desc: Create a new dotnet Console application.
cmds:
- "dotnet new console --output ./src/{{.PROJ}}"
- "dotnet new xunit --output ./test/{{.PROJ}}Test"
- "dotnet add ./test/{{.PROJ}}Test/{{.PROJ}}Test.csproj reference ./src/{{.PROJ}}/{{.PROJ}}.csproj"
- "dotnet new sln"
- "dotnet sln add ./src/{{.PROJ}}/{{.PROJ}}.csproj"
- "dotnet sln add ./test/{{.PROJ}}Test/{{.PROJ}}Test.csproj"
- echo "Now, add <IsPublishable>false</IsPublishable> to the Test Project's csproj."
add-console:
desc: Add a new dotnet Console Project.
cmds:
- "dotnet new console --output ./src/{{.PROJ}}"
- "dotnet new xunit --output ./test/{{.PROJ}}Test"
- "dotnet add ./test/{{.PROJ}}Test/{{.PROJ}}Test.csproj reference ./src/{{.PROJ}}/{{.PROJ}}.csproj"
- "dotnet sln add ./src/{{.PROJ}}/{{.PROJ}}.csproj"
- "dotnet sln add ./test/{{.PROJ}}Test/{{.PROJ}}Test.csproj"
- echo "Now, add <IsPublishable>false</IsPublishable> to the Test Project's csproj."
restore:
desc: Pull down the NuGet dependencies
cmds:
- dotnet restore
build:
desc: Build the dotnet Project
cmds:
- dotnet build
test:
desc: Run the dotnet Project Tests
cmds:
- dotnet test
run:
desc: Run the dotnet Project
cmds:
- "dotnet ./src/{{.PROJ}}/bin/Debug/net6.0/{{.PROJ}}.dll"
publish:
desc: Publish the dotnet Project
cmds:
- dotnet publish --runtime linux-x64 --configuration Release
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment