-
-
Save edgamat/29be20f87a0f94614597d6e93bc265f9 to your computer and use it in GitHub Desktop.
PowerShell script to create a new dotnet solution (.NET 8.0.1)
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 ( | |
[string]$projectName | |
) | |
mkdir "$projectName" | |
# Ensure the SDK is locked in so the solution is independent of other SDK versions | |
cd "$projectName" | |
dotnet new globaljson --sdk-version 8.0.101 --roll-forward minor | |
dotnet new editorconfig | |
cd ..\ | |
mkdir "$projectName\src\$projectName.Domain" | |
# Create the class library for the Domain business logic | |
cd "$projectName\src\$projectName.Domain" | |
dotnet new classlib --no-restore | |
dotnet user-secrets init --id "$projectName" | |
cd ..\..\..\ | |
mkdir "$projectName\test\UnitTests.$projectName.Domain" | |
# Create the class library for the Domain business logic unit tests | |
cd "$projectName\test\UnitTests.$projectName.Domain" | |
dotnet new xunit --no-restore | |
dotnet add reference "..\..\src\$projectName.Domain\$projectName.Domain.csproj" | |
cd ..\..\..\ | |
# Create the Solution file | |
cd "$projectName" | |
dotnet new sln -n "$projectName" | |
dotnet sln add ".\src\$projectName.Domain\$projectName.Domain.csproj" | |
dotnet sln add ".\test\UnitTests.$projectName.Domain\UnitTests.$projectName.Domain.csproj" | |
cd ..\ | |
mkdir "$projectName\src\$projectName.UI" | |
cd "$projectName\src\$projectName.UI" | |
dotnet new webapi --no-restore | |
dotnet user-secrets init --id "$projectName" | |
dotnet add reference "..\$projectName.Domain\$projectName.Domain.csproj" | |
cd ..\..\..\ | |
mkdir "$projectName\test\UnitTests.$projectName.UI" | |
cd "$projectName\test\UnitTests.$projectName.UI" | |
dotnet new xunit --no-restore | |
dotnet add reference "..\..\src\$projectName.Domain\$projectName.Domain.csproj" | |
dotnet add reference "..\..\src\$projectName.UI\$projectName.UI.csproj" | |
cd ..\..\..\ | |
cd "$projectName" | |
dotnet sln add ".\src\$projectName.UI\$projectName.UI.csproj" | |
dotnet sln add ".\test\UnitTests.$projectName.UI\UnitTests.$projectName.UI.csproj" | |
cd .. | |
# Create a .gitignore file | |
cd "$projectName" | |
$url = "https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore" | |
$output = ".gitignore" | |
Invoke-WebRequest -Uri $url -OutFile $output | |
git init | |
git add . | |
git commit -m "Initial commit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment