Last active
October 26, 2021 18:20
-
-
Save AlexKorsakov/bea61d3b43cb90e790cdfb6c1cb67e3a to your computer and use it in GitHub Desktop.
DotnetSolutionCreator creates dotnet solution with console app faster than you do it by Visual Studio. Optionally, you can add a unit test project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[Parameter(Mandatory=$true, Position=1)] | |
[string]$name = "TestSolution", | |
[Alias('t')] | |
[Parameter(Mandatory=$false,Position=2)] | |
[switch]$isAddTestProject | |
) | |
New-Item -Path "." -Name $name -ItemType "directory" | |
Set-Location -Path $name | |
$slnPath = '{0}.sln' -f $name | |
$mainProjectName = '{0}/{0}.csproj' -f $name | |
dotnet new sln -n $name | |
dotnet new console -o $name | |
Write-Host "...Solution with name '$slnPath' created" | |
if ($isAddTestProject) | |
{ | |
$testsFolderName = '{0}.Tests' -f $name | |
$testsProjectPath = '{0}/{0}.csproj' -f $testsFolderName | |
dotnet new nunit -n $testsFolderName | |
dotnet add $testsProjectPath reference $mainProjectName | |
Write-Host "...Tests project created" | |
} | |
dotnet sln $slnPath add (ls -r **/*.csproj) | |
dotnet new gitignore | |
Write-Host "...gitignore created" | |
Set-Location -Path ".\.." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.\create-sln.ps1 TestConsole -t