Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Created August 7, 2018 19:37
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 takekazuomi/8866dde950e424eb75569c13aa0e2c72 to your computer and use it in GitHub Desktop.
Save takekazuomi/8866dde950e424eb75569c13aa0e2c72 to your computer and use it in GitHub Desktop.
psakefile for new netcore console projects
Properties {
$projects = @(
@{
template="console"
name = "diconsole"
}
@{
template="classlib"
name = "classlib01"
}
@{
template="classlib"
name = "classlib02"
}
@{
template="classlib"
name = "classlib03"
}
)
}
Task default -Depends Test
Task Test -Depends Compile, Clean {
"This is a test"
}
Task Compile -Depends Clean {
"Compile"
}
Task Clean {
"Clean"
}
Task New -Depends New-Projects, New-Sln {
}
Task New-Projects {
$projects | %{
dotnet new $_.template -o "src/$($_.name)" --force
if($_.template -eq "classlib"){
dotnet new xunit -o "tests/$($_.name)" --force
}
}
}
Task New-Sln {
dotnet new sln -n diconsole --force
$csprojs = (Get-ChildItem -Recurse -Include *.csproj).FullName | Resolve-Path -Relative
dotnet sln add $csprojs
# get default .gitignore from github
Invoke-WebRequest https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore -OutFile .gitignore
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment