diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e543272..84689e0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" -} +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index f74c15a..583bea0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,4 +1,3 @@ - { "version": "0.2.0", "configurations": [ @@ -17,7 +16,11 @@ "kind": "bin" } }, - "args": [] + "args": [], + // 添加环境变量解决文件锁问题 + "env": { + "CARGO_REGISTRIES_CRATES_IO_PROTOCOL": "sparse" + }, } ] } \ No newline at end of file diff --git a/.vscode/task.json b/.vscode/task.json new file mode 100644 index 0000000..65171bf --- /dev/null +++ b/.vscode/task.json @@ -0,0 +1,25 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "cargo-clean-build", + "type": "process", + "command": "cargo", + "args": [ + "build", + "--bin=hello_remote_world", + "--package=hello_remote_world" + ], + "group": "build", + "problemMatcher": ["$rustc"], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false + } + } + ] +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 0c469d5..5a38cfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hello_remote_world" version = "0.1.0" -authors = ["VS Code "] +edition = "2021" [lib] path ="./src/lib/lib.rs" diff --git a/README.md b/README.md index 632e2de..a0f18db 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# base - +# Rust Rust 基础开发环境镜像模板项目 Rust 项目工程模板