首页 > 解决方案 > vscode 工作空间可以使用相对路径

问题描述

我想制作一个 AMX mod X 脚本,这个模块与我制作的游戏有关,所以我使用工作区作为配置。使编译器、库和输出路径依赖于每个游戏。我的源代码与编译器具有相同的文件夹

我试着写了./.\\但它不起作用,vscode仍然找不到amxxpc.exe,这是我的配置工作区:

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "amxxpawn.compiler.executablePath": "./amxxpc.exe",
        "amxxpawn.compiler.includePaths": [
            "./include"
        ],
        "amxxpawn.compiler.outputPath": "../plugins",
        "amxxpawn.compiler.outputType": "path"
    }
}

amxxpawn.compiler.executablePath在我写完完整路径之前,仍然无法计算 amxxpc.exe。由于它与源代码位于同一文件夹中,因此我也尝试删除./但仍找不到它。

这是我使用的扩展:https ://marketplace.visualstudio.com/items?itemName=KliPPy.amxxpawn-language

标签: visual-studio-codevscode-settingspawn

解决方案


这并不总是在每个扩展中都有效,但我将工作区设置中的每个配置移动到user.json然后${workspaceFolder}用作相对变量,例如:

"amxxpawn.compiler.includePaths": [
            "${workspaceFolder}/include"
        ]

工作区仍在使用,但我独自离开它,也使folder价值意味着文件的位置pathpath.workspace


推荐阅读