[Convert] vscode debugging and running c # detailed operation process
Main commands:
//Path Jump
cd
//New Project
Dotnet new console - o path
//Run
dotnet run
//Used to publish exe
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
//Execute the command in the project root directory:
Run program:
dotnet run -p ceshi002.csproj
Publish exe:
dotnet publish ceshi002.csproj
Tutorial Start:
1. Installation NET Core SDK. //It's OK to confirm all the installation
. NET Core SDK Download
2. Install Visual Studio Code
Visual Studio Code. Download
3. Install the C # extension in the VSCode market, and search directly
4. First try to create a C # program and run it with cmd
1. Shortcut key: win+R
2. Enter dotnet - h to view help:
3. Specify a project folder anywhere:
4. Then use the command in cmd to specify the path to create a new project:
Input:
Dotnet new console - o D: c # cmd test myceshi001
new It is initialization NET project
console Is a template
-o Is where you want to place the generated output.
Followed by path D: C # cmd test myceshi001
myceshi001 Is the name of the project
5. At this time, the myceshi001 project has been created in the folder:
There is a Hello World program generated automatically by the system!!!
6. Enter the project path in cmd and try to run:
Input d: Jump to disk d
input Cd path Jump to project path
input dotnet run Try running
success!!!
7. You can also view the file text content by entering type in cmd:
Note: Input help Can view cmd commands
5. Create and run with vscode:
1. Create a project folder://Here I create a c # vscode test
2. Open vscode:
3. Open this folder in vscode:
Shortcut key: ctrl+k+ctrl+o
2. Shortcut key: ctrl+shifit+y to open the console
3. Enter the terminal
2. The next creation operation is the same as that of the above cmd:
Typing code:
dotnet new console
Restore succeeded!!!
Then there is something more in the folder
Click to open Program.cs, which is the main program file you created
It has written a Hello World program by default
3. Next, press F5 directly to run!!!
He will let you select the environment to run, click NET Core
4. After waiting for some time
Jump out a json file and let you set?
A warning pops up:
Missing c # vscode tests for required asset building and debugging. Join them?
Click: yes
Then close the file
The first run will be like this
5. After setting, press F5
After waiting for some time
Successfully printed Hello world on the debug console!
Some generation information is displayed on the terminal:
............. Perfect operation!!!
6. Start writing your own program and debugging:
Write an example:
New class file named Name001
And then added a breakpoint
Then call in the main program
Then press F5 to run!!!
Enter the debugging page:
Debugging breakpoint monitoring is complete!!!
Successful output: Hello World! Lightning hacker
The tutorial of vscode running C # debugging is over...
Last Last:
You should have found out
There is no exe file in debug, only a dll?
terms of settlement:
In the project Add this line of code to the csproj file:
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
Then click F5 to run:
Note: If the exe is generated, the compilation wait time will be long
When you finish, you can open the folder and see more things
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
Used for final exe generation...
New programs will be generated in win10-x64
However, vscode is still the. dll program in netcoreapp 2.1 before debugging
Will not debug the new path win10-x64
It is recommended to make sure that the program is completed and used to generate. exe
//=============================================
Of course, if you don't mind the trouble, you can add another short path:
Open the launch.json file in the. vscode folder
Inside:
"Program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/C # vscode test. dll",
Is the debug path: add win10-x64/after netcoreapp2.1/to become: "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/win10-x64/C # vscode test. dll",
Then there is no problem at all. Debug and generate new exe at the same time, all in win10-x64
---------------------
Author: Lightning Y Hacker
Source: CSDN
Original text: https://blog.csdn.net/qq_40346899/article/details/80955788
Copyright notice: This is an original article of the blogger. Please attach a link to the blog for reprinting!