C、C++、C#中.vscode下json文件记录

news/2024/12/29 4:16:01/

C

launch.json

{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) 启动","type": "cppdbg","request": "launch",// "program": "输入程序名称,例如 ${workspaceFolder}/a.exe","program": "${fileDirname}\\test.exe","args": [],"stopAtEntry": false,"cwd": "${fileDirname}","environment": [],"externalConsole": false,"MIMode": "gdb",// "miDebuggerPath": "/path/to/gdb","miDebuggerPath": "D:\\Softwares\\mingw64\\bin\\gdb.exe","setupCommands": [{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "将反汇编风格设置为 Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true}]}]
}

tasks.json

{"tasks": [{"type": "cppbuild","label": "C/C++: gcc.exe 生成活动文件","command": "D:\\Softwares\\mingw64\\bin\\gcc.exe","args": ["-fdiagnostics-color=always","-g",// "${file}","*.c","-o",// "${fileDirname}\\${fileBasenameNoExtension}.exe""${fileDirname}\\test.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}],"version": "2.0.0"
}

C++

launch.json

{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "C/C++: g++.exe build and debug active file", // 配置名称,将会在启动配置的下拉菜单中显示"type": "cppdbg",  // 配置类型,这里只能为cppdbg"request": "launch",  // 请求配置类型,可以为launch(启动)或attach(附加)// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe","program": "${fileDirname}\\test.exe",  // 将要进行调试的程序的路径"args": [],  // 程序调试时传递给程序的命令行参数,一般设为空即可"stopAtEntry": false,  // 设为true时程序将暂停在程序入口处,一般设置为false"cwd": "${fileDirname}",  // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录"environment": [],"externalConsole": false,  // 调试时是否显示控制台窗口,一般设置为true显示控制台"MIMode": "gdb",// "miDebuggerPath": "C:\\msys64\\ucrt64\\bin\\gdb.exe","miDebuggerPath": "D:\\Softwares\\mingw64\\bin\\gdb.exe",  // miDebugger的路径,注意这里要与MinGw的路径对应"setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "Set Disassembly Flavor to Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true}],"preLaunchTask": "C/C++: g++.exe build active file"   // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc}]
}

tasks.json

{"tasks": [{"type": "cppbuild","label": "C/C++: gcc.exe 生成活动文件","command": "D:\\Softwares\\mingw64\\bin\\gcc.exe","args": ["-fdiagnostics-color=always","-g","*.c","-o","${fileDirname}\\test.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": "build","detail": "调试器生成的任务。"},{"type": "cppbuild","label": "C/C++: g++.exe 生成活动文件","command": "D:\\Softwares\\mingw64\\bin\\g++.exe","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}],"version": "2.0.0"
}

settings.json

{"files.defaultLanguage": "c", // ctrl+N新建文件后默认的语言"editor.formatOnType": true,  // 输入分号(C/C++的语句结束标识)后自动格式化当前这一行的代码"editor.suggest.snippetsPreventQuickSuggestions": false, // clangd的snippets有很多的跳转点,不用这个就必须手动触发Intellisense了"editor.acceptSuggestionOnEnter": "off", // 我个人的习惯,按回车时一定是真正的换行,只有tab才会接受Intellisense// "editor.snippetSuggestions": "top", // (可选)snippets显示在补全列表顶端,默认是inline"code-runner.runInTerminal": true, // 设置成false会在“输出”中输出,无法输入"code-runner.executorMap": {"c": "gcc '$fileName' -o '$fileNameWithoutExt.exe' -Wall -O2 -m64 -lm -static-libgcc -fexec-charset=GBK -D__USE_MINGW_ANSI_STDIO && &'./$fileNameWithoutExt.exe'","cpp": "g++ '$fileName' -o '$fileNameWithoutExt.exe' -Wall -O2 -m64 -static-libgcc -fexec-charset=GBK && &'./$fileNameWithoutExt.exe'"// "c": "gcc $fileName -o $fileNameWithoutExt.exe -Wall -O2 -m64 -lm -static-libgcc -fexec-charset=GBK -D__USE_MINGW_ANSI_STDIO && $dir$fileNameWithoutExt.exe",// "cpp": "g++ $fileName -o $fileNameWithoutExt.exe -Wall -O2 -m64 -static-libgcc -fexec-charset=GBK && $dir$fileNameWithoutExt.exe"}, // 右键run code时运行的命令;未注释的仅适用于PowerShell(Win10默认)和pwsh,文件名中有空格也可以编译运行;注释掉的适用于cmd(win7默认)、PS和bash,但文件名中有空格时无法运行"code-runner.saveFileBeforeRun": true, // run code前保存"code-runner.preserveFocus": true,     // 若为false,run code后光标会聚焦到终端上。如果需要频繁输入数据可设为false"code-runner.clearPreviousOutput": false, // 每次run code前清空属于code runner的终端消息,默认false"code-runner.ignoreSelection": true,   // 默认为false,效果是鼠标选中一块代码后可以单独执行,但C是编译型语言,不适合这样用"code-runner.fileDirectoryAsCwd": true, // 将code runner终端的工作目录切换到文件目录再运行,对依赖cwd的程序产生影响;如果为false,executorMap要加cd $dir"C_Cpp.clang_format_sortIncludes": true, // 格式化时调整include的顺序(按字母排序)
}

C#

launch.json

{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{// Use IntelliSense to find out which attributes exist for C# debugging// Use hover for the description of the existing attributes// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md"name": ".NET Core Launch (console)",  // 配置名称"type": "coreclr",  // 配置类型(编程环境)"request": "launch",  // 请求配置类型,可以是launch启动或attach附加"preLaunchTask": "build",  // 调试会话开始前执行的任务,一般为编译程序。与tasks.json的label相对应// If you have changed target frameworks, make sure to update the program path."program": "${workspaceFolder}/csharp/test/bin/Debug/net8.0/test.dll",  // 需要更改文件路径 将要进行调试的程序的路径"args": [],  // 程序调试时传递给程序的命令行参数,一般设为空即可"cwd": "${workspaceFolder}/csharp",  // 需要更改路径 调试程序时的工作目录// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console"console": "internalConsole",  // “控制台”设置控制目标应用程序启动到哪个控制台(终端)窗口 internalConsole:内部控制台  integratedTerminal:内部终端  externalTerminal:外部终端"stopAtEntry": false  // 设为true时程序将暂停在程序入口处,我一般设置为true},{"name": ".NET Core Attach","type": "coreclr","request": "attach"}]
}

settings.json


{"update.showReleaseNotes": false,"update.enableWindowsBackgroundUpdates": false,"update.mode": "none","code-runner.runInTerminal": true,"code-runner.executorMap": {"javascript": "node","java": "cd $dir && javac $fileName && java $fileNameWithoutExt","c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","zig": "zig run","cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","php": "php","python": "python -u","perl": "perl","perl6": "perl6","ruby": "ruby","go": "go run","lua": "lua","groovy": "groovy","powershell": "powershell -ExecutionPolicy ByPass -File","bat": "cmd /c","shellscript": "bash","fsharp": "fsi","csharp": "cd $dir && dotnet run $fileName","vbscript": "cscript //Nologo","typescript": "ts-node","coffeescript": "coffee","scala": "scala","swift": "swift","julia": "julia","crystal": "crystal","ocaml": "ocaml","r": "Rscript","applescript": "osascript","clojure": "lein exec","haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt","rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt","racket": "racket","scheme": "csi -script","ahk": "autohotkey","autoit": "autoit3","dart": "dart","pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt","d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt","haskell": "runghc","nim": "nim compile --verbosity:0 --hints:off --run","lisp": "sbcl --script","kit": "kitc --run","v": "v run","sass": "sass --style expanded","scss": "scss --style expanded","less": "cd $dir && lessc $fileName $fileNameWithoutExt.css","FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","sml": "cd $dir && sml $fileName","mojo": "mojo run"}
}

配置VSCode及运行C#文件

vscode 安装插件    vscode-solution-explorer
       安装C#语言  @id:ms-dotnettools.csharp


安装.net后
cmd  dotnet --version    dotnet -h
code . 在当前工作目录中启动VSCode


新建目录,将目录添加到vscode中
dotnet new console -o test  新建应用控制台应用,名称为test

输入命令dotnet run运行一直报错: Unable to find fallback package folder  
NuGet.Packaging.Core.PackagingException: 无法找到回退包文件夹“D:\Softwares\Microsoft Visual Studio\Shared\NuGetPackages

解决,删除NuGet文件夹
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
并在扩展中添加Nuget Package Manager

快捷键
ctrl+shift+Y  打开调试控制台
          +P  打开上方工作区  可以新建项目
          +X  打开扩展


task.json 为编译文件
launch.json 为调试文件  设置调试配置文件
setting.json  
{
    "update.showReleaseNotes": false,
    "update.enableWindowsBackgroundUpdates": false,
    "update.mode": "none",
    "code-runner.runInTerminal": true,
    添加  code-runner.executorMap,回车后自动添加大量内容
}
找到csharp,将scripts 改为 cd $dir && dotnet run $fileName


配置后,安装run code后,直接可以执行 ctrl+alt+N,运行Program.cs文件


如果bin文件夹中没有生成exe文件,在xxx.csproj中添加 <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
 


http://www.ppmy.cn/news/1405952.html

相关文章

jvm总结学习

四种加载器 1.启动类加载器 2.拓展类加载器 3.应用程序加载器 4.自定义加载器 沙箱机制 就是为了保证安全&#xff0c;增加的一些权限。 native方法区&#xff08;静态变量&#xff0c;常量&#xff0c;类信息&#xff08;构造方法&#xff0c;接口定义&#xff09;&…

【前端webpack5高级优化】提升打包构建速度几种优化方案

HotModuleReplacement&#xff08;HMR/热模块替换&#xff09; 开发时我们修改了其中一个模块代码&#xff0c;Webpack 默认会将所有模块全部重新打包编译&#xff0c;速度很慢 所以我们需要做到修改某个模块代码&#xff0c;就只有这个模块代码需要重新打包编译&#xff0c;…

AJAX —— 学习(三)

目录 一、jQuery 中的 AJAX &#xff08;一&#xff09;get 方法 1.语法介绍 2.结果实现 &#xff08;二&#xff09;post 方法 1.语法介绍 2.结果实现 &#xff08;三&#xff09;通用型的 AJAX 方法 1.语法介绍 2.结果实现 二、AJAX 工具库 axios &#xff08;…

Doris实践——同程数科实时数仓建设

目录 前言 一、早期架构演进 二、Doris和Clickhouse选型对比 三、新一代统一实时数据仓库 四、基于Doris的一站式数据平台 4.1 一键生成任务脚本提升任务开发效率 4.2 自动调度监控保障任务正常运行 4.3 安全便捷的可视化查询分析 4.4 完备智能的集群监控 五、收益与…

redis---位图Bitmap和位域 Bitfield

位图是字符串类型的拓展&#xff0c;可以使用一个string类型来模拟一个Bit数组。数组的下标就是偏移量&#xff0c;值只有0和1&#xff0c;也支持一些位运算&#xff0c;比如与或非&#xff0c;异或等等&#xff0c;它们的应用场景非常广泛比如可以用来记录用户的签到情况&…

使用 Flume 将 CSV 数据导入 Kafka:实现实时数据流

使用 Flume 将 CSV 数据导入 Kafka&#xff1a;实现实时数据流 文介绍了如何使用 Apache Flume 将 CSV 格式的数据从本地文件系统导入到 Apache Kafka 中&#xff0c;以实现实时数据流处理。通过 Flume 的配置和操作步骤&#xff0c;我们可以轻松地将数据从 CSV 文件中读取并发…

Nginx从安装到高可用实用教程!

一、Nginx安装 1、去官网http://nginx.org/下载对应的nginx包&#xff0c;推荐使用稳定版本 2、上传nginx到linux系统 3、安装依赖环境 (1)安装gcc环境 yum install gcc-c(2)安装PCRE库&#xff0c;用于解析正则表达式 yum install -y pcre pcre-devel(3)zlib压缩和解压缩…

焦糖布丁理论:从用户任务角度重新审视产品价值

一、引言&#xff1a; 在竞争激烈的市场环境中&#xff0c;我们经常会遇到这样的困惑&#xff1a;为什么一款自认为极具创新和品质的产品&#xff0c;却未能获得市场的青睐和认可&#xff1f;焦糖布丁理论为我们提供了一个全新的视角&#xff0c;即”客户并非在购买产品本身&a…