Working on bigger projects using VSCode with rust-analyzer

I'm trying to convert a rather complex application into Rust. Therefore I've split the project into several repositories, containing several crates and cargo workspaces depending on each other.

The initial development will be mainly about filling in the module structure of all crates and a good amount of refactoring. Here are my problems:

Multiple targets in single workspace
It seems to be hard to have multiple targets in a single cargo workspace. Building the root doesn't respect the default target (set via .cargo/config.toml) of the crate. While this is just annoying from the command line, it's a real problem in VSCode and rust-analyzer.

I needed this for a workspace containing a portable library and several platform dependent (native, WASM) launchers.

The workaround was to move the launchers out of the workspace.
A similar problem were examples with different compilation targets. I had to move them into a separate crate (one for each target).

Working on multiple crates

The project comprises of about 20 (top-level-)crates and workspaces. When working on several crates simultaneously I have three choices:

  • Open one VSCode instance per crate. This gives the best support from the IDE and rust-analyzer but makes it hard to do global searches and refactorings. Another problem is, that when I change something in another crates (jump to source makes this quite convenient), VSCode doesn't refresh the analysis and keeps reporting all sorts of errors until I re-open the entire project.
  • Open the root directory of all crates within this project. rust-analyzer reports a missing manifest. While this can be somewhat fixed by adding a virtual cargo workspace (doesn't work with nested workspaces, I think) it has the multi-target problem. Also VSCode only reads their config from the root level, and doesn't respect the per-project settings.
  • Create a VSCode-workspace and add the crates as folders. rust-analyzer still ignores its settings about the build target. One cannot set the target as folder setting - only for the entire workspace

I don't think my use-case is too weird so I'm likely missing something here. Are there best practices for working on multi-crate projects?

Sometime asking here loosens the brain. Will try this now: Open multiple Projects/Folders in Visual Studio Code - Stack Overflow

Ok, that solved the multi-crate scenario but rust-analyzer still doesn't work with multiple targets. Even when they're associates with a crate at top level.
The only WASM-crate gets compiled with the wrong target.

You can work around this by giving each workspace folder a .vscode/tasks.json file which explicitly defines the built-in tasks supplied by rust-analyzer. The "Tasks" section of the VSCode documentation explains it pretty clearly:

Example scenario: I've created 2 separate binaries, app1 and app2, added them to a new workspace in VSCode, and put the following .vscode/tasks.json files in both folders:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "rust: cargo build",
            "type": "shell",
            "command": "cargo build"
        }
    ]
}

Now if I select Tasks: Run Task from the command palette (I have it configured for Ctrl+Shift+R), I have 2 separate rust: cargo build tasks for each folder:

Thanks. I'm fairly new to VSCode.
I launched the task using "Terminal"/"Run Task"/"cargo build (my_project)"/"continue without scanning the task output".

It successfully builds the project (no difference from building directly in the terminal). But the errors shown in the IDE are still the same.

Opening the crate in question as a single project works fine since rust-analyzer evaluates my settings.json which contains the correct target.