Skip to content

Latest commit

 

History

History

VSCodeIntro

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

C# Starter using VSCode

Setup

  • install .NET Core 3.1 SDK (v3.1.201) for Mac
  • install VSCode extension
    • ms-dotnettools.csharp
    • ms-mssql.mssql
    • jmrog.vscode-nuget-package-manager
    • eamodio.gitlens (optional)
    • vscode-icons-team.vscode-icons (optional)

Create App

  • create solution and projects from the video
cd VSCodeIntro/
# create solution
dotnet new sln -n "VSCodeIntroSln"
# create project
dotnet new console -n "IntroUI"
# create library
dotnet new classlib -n "IntroLibrary"
# add project and library to solution
dotnet sln VSCodeIntroSln.sln add **/*.csproj
# create reference to library
dotnet add IntroUI/IntroUI.csproj reference IntroLibrary/IntroLibrary.csproj
# open each directories and answer Yes when asked required assets missing
code IntroUI/
code .
# check launch.json have program IntroUI.dll

NuGet

# NuGet from CLI
cd IntroLibrary/
dotnet add package Dapper
# add Dapper to IntroLibrary.csproj copy <ItemGroup>...</ItemGroup>
# paste to IntroUI.csproj and click Restore as suggested

# NuGet from View > Command Palette
# NuGet Package Manager: Add Package > SeriLog
# select the latest version then click Restore
  • In case VSCode didn't suggest to restore, run manually
cd VSCodeIntro/
dotnet restore

Editing Shortcuts

  • cw: System.Console.WriteLine();
  • prop: class property

Database Connection

  • install from NuGet Package Manager
    • Dapper
    • Microsoft.Data.SqlClient
    • System.Configuration.ConfigurationManager
  • follow the Getting Started at https://dapper-tutorial.net/

Run

  • VSCode menu Run > Run Without Debugging
  • You should see the query result

Reference