---
# System prepended metadata

title: Create/Build dotnet project in VSCode

---

# Create/Build dotnet project in VSCode

## dotnet cli 
### new 
```
dotnet new list
```

### Step1 Create solution
```
dotnet new sln --name dotnet-cli-demo
```
### Step2 Add gitignore
```
dotnet new gitignore
```
### Step3 Create console app project
```
 dotnet new console --name console-ui
 ## you can also add -f to select framework
 dotnet new console --name console-ui -f net6.0  
 dotnet new console --name console-ui -f net7.0  
```
### Step4 Create lib project
```
dotnet new classlib --name helper-lib  
```
### Step5 Add project list to solution
```
dotnet sln dotnet-cli-demo.sln add console-ui/console-ui.csproj
dotnet sln dotnet-cli-demo.sln add helper-lib/helper-lib.csproj
```
### Step5 Add Reference project in `console-ui`
```
dotnet add console-ui/console-ui.csproj reference helper-lib/helper-lib.csproj 
```
### Step6 Add NuGet package in `helper-lib`
```
cd helper-lib
dotnet add package Dapper
```
### Step7 Start debug app
`ctrl+shift+P` to run the app


### Others
#### Find sdks version
```
$ dotnet --list-sdks
6.0.400 [/usr/local/share/dotnet/sdk]
6.0.404 [/usr/local/share/dotnet/sdk]
6.0.405 [/usr/local/share/dotnet/sdk]
6.0.406 [/usr/local/share/dotnet/sdk]
6.0.407 [/usr/local/share/dotnet/sdk]
7.0.100 [/usr/local/share/dotnet/sdk]
7.0.101 [/usr/local/share/dotnet/sdk]
7.0.102 [/usr/local/share/dotnet/sdk]
7.0.200 [/usr/local/share/dotnet/sdk]
7.0.202 [/usr/local/share/dotnet/sdk]
```
#### Find current default version
```
$ dotnet --version
7.0.202
```

#### Set default version in project 
create `globaljson` in project root
```
dotnet new globaljson --sdk-version x.y.z

```