You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code调试C#应用时传递环境变量失败的问题排查

在VS Code中调试C#应用时传递环境变量遇到的问题

我在Visual Studio Code中调试C#应用时,尝试传递环境变量。根据官方文档说明,需在launch.json中使用"env"字段,但VS Code的智能感知标记该字段无效,应用无法读取声明的环境变量。使用"environmentVariables"字段也得到相同结果,而使用"environment"字段时,构建会出现“Error processing launch options at field:”错误。

智能感知提示:Property env is not allowed. Property environment is not allowed.
构建错误:Error processing launch options at field:

以下是我的launch.json配置:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C#: <project name snipped> Debug",
            "type": "dotnet",
            "request": "launch",
            "projectPath": "${workspaceFolder}/<project name snipped>.csproj",
            "env": {
                "DATA_ROOT": "./data"
            }
        }
    ]
}

内容的提问来源于stack exchange,提问作者MiffTheFox

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 10:37:34