How to create a solution of .net core? For example: 1 Web Project 3 Lib Projects
How to create it without Visual Studio?
Using VS Code or Sublime Text?
If you have dotnet core installed just create a root folder for your solution. Then open terminal in root folder and type for a mvc project:
dotnet new mvc -o SolutionName.Web
remember -o parameter creates a folder for new project and if it was -n project was going to be created in the folder you are in.
and for class library project
dotnet new classlib -o SolutionName.Library
cd SolutionName.Web
this line to add reference to use this library.
dotnet add reference ../SolutionName.Library/SolutionName.Library.csproj
get to root folder again
cd..
dotnet new sln -n SolutionName
we talked about -n. After we created solution we will add projects to solution.
dotnet sln add SolutionName.Web/SolutionName.Web.csproj
dotnet sln add SolutionName.Library/SolutionName.Library.csproj
dotnet build
if you are using vs code just type
code .
in the root of solution in terminal and you will start coding.
Here is an example project referenced from Microsofts Docs website ( https://github.com/dotnet-architecture/eShopOnWeb ). As you can see, inside of the src folder they break up the 'solution' into three 'projects', 'web', 'infrastructure' and 'applicationCore'.
This is one way to do it using PowerShell and the dotnet
command line interface .
Create directories for the Web and Lib projects.
New-Item -Type Directory Web
New-Item -Type Directory Lib01
New-Item -Type Directory Lib02
New-Item -Type Directory Lib03
Create the Web Project
cd .\Web\
dotnet new --lang C# --type Web
cd ..
Create the three Lib projects.
cd .\Lib01\
dotnet new --lang C# --type Lib
cd ..
cd .\Lib02\
dotnet new --lang C# --type Lib
cd ..
cd .\Lib03\
dotnet new --lang C# --type Lib
cd ..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.