Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create new ASP.NET Core solution with Entities class library, Data class library and Web MVC project
# create new solution based on input argument
create_new_solution () {
local root_dir=$1
echo creating solution : $root_dir
# create solution directory
mkdir $root_dir
dotnet new sln -o $root_dir
cd $root_dir && mkdir src && cd src
create_projects $root_dir
# create base projects
create_projects () {
local root_dir=$1 # store root directories
# create web project
echo creating web project
local web_dir=$root_dir.Web
create_proj mvc $web_dir $root_dir
echo 'done creating ' $web_dir
# create project names
all_projs='Entities Data'
for proj in $all_projs
local current_proj=$root_dir.$proj
echo creating project $current_proj
create_proj classlib $current_proj $root_dir
echo 'done creating ' $current_proj
echo adding ref to web
add_inter_proj_refs $root_dir.Web $current_proj
echo added $current_proj to $root_dir.Web
# add entity ref to data
add_inter_proj_refs $root_dir.Data $root_dir.Entities
# create project
create_proj () {
local proj_type=$1
local proj_dir=$2
local root_dir=$3
mkdir $proj_dir
dotnet new $proj_type -o $proj_dir
add_sln_reference $root_dir $proj_dir
# add solution refernce to project
add_sln_reference() {
dotnet sln ../$1.sln add $2/$2.csproj
# inter refs between projects
add_inter_proj_refs() {
dotnet add $1/$1.csproj reference $2/$2.csproj
# trigger solution creation
create_new_solution $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment