添加构建调试
This commit is contained in:
		@@ -1,31 +1,57 @@
 | 
			
		||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
 | 
			
		||||
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
 | 
			
		||||
{
 | 
			
		||||
	"name": "Rust",
 | 
			
		||||
	// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
 | 
			
		||||
	"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
 | 
			
		||||
 | 
			
		||||
	// Features to add to the dev container. More info: https://containers.dev/features.
 | 
			
		||||
	// "features": {},
 | 
			
		||||
	"postStartCommand": "cargo run",
 | 
			
		||||
	// 先构建项目,但不自动运行
 | 
			
		||||
	"postStartCommand": "cargo build && clear",
 | 
			
		||||
 | 
			
		||||
	// Configure tool-specific properties.
 | 
			
		||||
	"customizations": {
 | 
			
		||||
		// Configure properties specific to VS Code.
 | 
			
		||||
		"vscode": {
 | 
			
		||||
			"settings": {},
 | 
			
		||||
			"extensions": [
 | 
			
		||||
				"streetsidesoftware.code-spell-checker"
 | 
			
		||||
			]
 | 
			
		||||
				"streetsidesoftware.code-spell-checker",
 | 
			
		||||
				"rust-lang.rust-analyzer",  // 添加 Rust 语言支持
 | 
			
		||||
				"vadimcn.vscode-lldb"       // 添加 LLDB 调试器支持
 | 
			
		||||
			],
 | 
			
		||||
			
 | 
			
		||||
			// 添加调试配置
 | 
			
		||||
			"debug": {
 | 
			
		||||
				"configurations": [
 | 
			
		||||
					{
 | 
			
		||||
						"type": "lldb",
 | 
			
		||||
						"request": "launch",
 | 
			
		||||
						"name": "Debug Rust Application",
 | 
			
		||||
						"program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}",
 | 
			
		||||
						"args": [],
 | 
			
		||||
						"cwd": "${workspaceFolder}",
 | 
			
		||||
						"preLaunchTask": "cargo-build"
 | 
			
		||||
					}
 | 
			
		||||
				]
 | 
			
		||||
			},
 | 
			
		||||
			
 | 
			
		||||
			// 添加构建任务
 | 
			
		||||
			"tasks": {
 | 
			
		||||
				"tasks": [
 | 
			
		||||
					{
 | 
			
		||||
						"type": "cargo",
 | 
			
		||||
						"command": "build",
 | 
			
		||||
						"problemMatcher": [
 | 
			
		||||
							"$rustc"
 | 
			
		||||
						],
 | 
			
		||||
						"group": "build",
 | 
			
		||||
						"label": "cargo-build"
 | 
			
		||||
					}
 | 
			
		||||
				]
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	
 | 
			
		||||
	// 转发应用端口(根据你的实际端口修改)
 | 
			
		||||
	"forwardPorts": [8080],
 | 
			
		||||
	"portsAttributes": {
 | 
			
		||||
		"8080": {
 | 
			
		||||
			"label": "Rust Application",
 | 
			
		||||
			"onAutoForward": "notify"
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Use 'forwardPorts' to make a list of ports inside the container available locally.
 | 
			
		||||
	// "forwardPorts": [],
 | 
			
		||||
 | 
			
		||||
	// Use 'postCreateCommand' to run commands after the container is created.
 | 
			
		||||
	// "postCreateCommand": "rustc --version",
 | 
			
		||||
 | 
			
		||||
	// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
 | 
			
		||||
	// "remoteUser": "root"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user