Skip to content

Instantly share code, notes, and snippets.

@jchannon
Last active September 13, 2016 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchannon/109147e2842ab844df64be5ec3eb4a52 to your computer and use it in GitHub Desktop.
Save jchannon/109147e2842ab844df64be5ec3eb4a52 to your computer and use it in GitHub Desktop.
VSCode tasks.json for building, restoring, executing tests on OSX with .Net Core

Info

This will require OSX and ZSH installed.

For tests it will require your directory name to match your namespace for tests as it uses the directory name to pass the namespace to xunit

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "zsh",
"isShellCommand": true,
"showOutput": "always",
"args": [
"-c"
],
"options": {
"cwd": "${fileDirname}"
},
"tasks": [
{
"taskName": "Build Current Project",
"suppressTaskName": true,
"isBuildCommand": true,
"args": [
"setopt extended_glob && print -l (../)#project.json(:h) | xargs dotnet build 2>&1 | grep -iv warning && echo Build Current Project Completed"
],
"problemMatcher": "$msCompile"
},
{
"taskName": "Build All Projects",
"suppressTaskName": true,
"isBuildCommand": true,
"args": [
"cd ${workspaceRoot} && dotnet build ./**/**/project.json && echo Build All Completed"
],
"problemMatcher": "$msCompile"
},
{
"taskName": "Restore All Projects",
"suppressTaskName": true,
"isBuildCommand": true,
"args": [
"cd ${workspaceRoot} && dotnet restore ./**/**/project.json --verbosity Information && echo Restore All Completed"
]
},
{
"taskName": "Restore Current Project",
"suppressTaskName": true,
"isBuildCommand": true,
"args": [
"setopt extended_glob && print -l (../)#project.json(:h) | xargs dotnet restore --verbosity Information && echo Restore Current Project Completed"
]
},
{
"taskName": "Run All Tests in Project",
"suppressTaskName": true,
"isBuildCommand": true,
"args": [
"setopt extended_glob && print -l (../)#project.json(:h) | xargs dotnet test && echo Tests Run Completed"
],
"problemMatcher": "$msCompile"
},
{
"taskName": "Run Tests in Class",
"suppressTaskName": true,
"isBuildCommand": true,
"args": [
"setopt extended_glob && print -l (../)#project.json(:h) | xargs -I@ dotnet test @ -class $(echo ${fileDirname} | sed 's/.*src\\///g' ).$(basename ${file} .cs) && echo Tests Run Completed"
],
"problemMatcher": "$msCompile"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment