Answers for "Run C# project in VS Code"

C#
3

setting up C# project with VSCode

# Setting up C# project with VSCode:

# 1. Open File Explorer and create a folder on your disk, then select the 
#    file path and to open the Command Prompt at the current path, type: cmd 
#    (For the purpose of this guide, the folder is called 'MyFolder')
#    The Command Prompt should look like this:
Microsoft Windows [Version 10.0.19043.1165]
(c) Microsoft Corporation. All rights reserved.

C:\Users\name\MyFolder>

# 2. Create .sln file and check the directory.
C:\Users\name\MyFolder>dotnet new sln -n "SlnFileName"
C:\Users\name\MyFolder>dir 
# ('dir' lists the content of the current directory so you
#  can check to see any files/folders updates)

# 3. Create new console project folder and check the directory.
C:\Users\name\MyFolder>dotnet new console -n "ProjectName"
C:\Users\name\MyFolder>dir

# 4. Create class library folder and check the directory.
C:\Users\name\MyFolder>dotnet new classlib -n "LibraryName"
C:\Users\name\MyFolder>dir
# (you could use 'cls' to clear the console and make it easier to read)

# 5. Add project to solution.
C:\Users\name\MyFolder>dotnet sln SlnFileName.sln add ./ProjectName/ProjectName.csproj

# 6. Add library to solution.
C:\Users\name\MyFolder>dotnet sln SlnFileName.sln add ./LibraryName/LibraryName.csproj

# 7. Project references the library.
C:\Users\name\MyFolder>dotnet add ProjectName/ProjectName.csproj reference LibraryName/LibraryName.csproj

# 8. Move the command line into a new project folder and check the directory.
C:\Users\name\MyFolder>cd ProjectName
C:\Users\name\MyFolder\ProjectName>dir

# 9. Launch VSCode from cmd. This will open VSCode with the current folder
#    already open. When VSCode has launched, there should be a little pop-up
#    message in the bottom right of the screen saying 'Required assets to
#    build and debug are missing from 'ProjectName'. Add them?'. You want to
#    click 'Yes' to add 'launch.json' and 'tasks.json' files.
C:\Users\name\MyFolder\ProjectName>Code ..

# 10. Now, close VSCode. In cmd, go back one folder, to 'MyFolder'. 
#     Lastly, open VSCode. Your default 'Program.cs' file should be located 
#     in the 'ProjectName' folder.
C:\Users\name\MyFolder\ProjectName>cd ..
C:\Users\name\MyFolder>Code ..

# Please comment if you have any queries/suggestions, or contact me (EAJB)
# on the Grepper Discord community.
Posted by: Guest on August-14-2021
11

how to make a C# application visual studio code

mkdir MyApp; cd MyApp;
dotnet new console
Posted by: Guest on June-09-2020
1

Run C# project in VS Code

dotnet run
Posted by: Guest on September-03-2021
-1

how to run csharp in visual studio code

/*
You should have a application if you want to create a application go 
the folder which is your project now use the command in the dir use the 
command dotnet new console to intialize it as a console application. Now 
You will the a file called {You workspace}.csproj go to the file and run it
*/
Posted by: Guest on June-24-2020

C# Answers by Framework

Browse Popular Code Answers by Language