Skip to content

Instantly share code, notes, and snippets.

@dburriss
Created July 14, 2017 09:20
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 dburriss/dde0c0ce68e120d4a51e4173e9533bff to your computer and use it in GitHub Desktop.
Save dburriss/dde0c0ce68e120d4a51e4173e9533bff to your computer and use it in GitHub Desktop.
Powershell command for creating a skeleton .net core solution
param (
#[string]$server = "http://defaultserver",
[Parameter(Mandatory=$true)][string]$domain
#[string]$password = $( Read-Host "Input password, please" )
)
# assumes in folder you want solution
# assumes dotnet CLi is on the PATH
# global vars
$root = Get-Location;
$src = "$root/src";
$test = "$root/test";
$slnName = Split-Path (Split-Path $root -Leaf) -Leaf
# create solution
dotnet new sln
# Domain project
if(!(Test-Path -Path $src )){
New-Item $src -ItemType Directory
}
if(!(Test-Path -Path "$src/$domain" )){
New-Item "$src/$domain" -ItemType Directory
cd "$src/$domain"
dotnet new classlib
cd $root
Invoke-Expression "dotnet sln $slnName.sln add $src/$domain/$domain.csproj"
}
# Unit test project
if(!(Test-Path -Path $test )){
New-Item $test -ItemType Directory
}
if(!(Test-Path -Path "$test/$domain.Tests.Unit" )){
New-Item "$test/$domain.Tests.Unit" -ItemType Directory
cd "$test/$domain.Tests.Unit"
dotnet new xunit
cd $root
Invoke-Expression "dotnet add $test/$domain.Tests.Unit/$domain.Tests.Unit.csproj reference $src/$domain/$domain.csproj"
Invoke-Expression "dotnet sln $slnName.sln add $test/$domain.Tests.Unit/$domain.Tests.Unit.csproj"
}
# WebApi project
if(!(Test-Path -Path "$src/$domain.Api" )){
New-Item "$src/$domain.Api" -ItemType Directory
cd "$src/$domain.Api"
dotnet new webapi
cd $root
Invoke-Expression "dotnet add $src/$domain.Api/$domain.Api.csproj reference $src/$domain/$domain.csproj"
Invoke-Expression "dotnet sln $slnName.sln add $src/$domain.Api/$domain.Api.csproj"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment