标签: visual-studio-code

使用 shell 命令作为 VSCode 任务变量值

我正在尝试定义一个 VSCode 任务tasks.json,以适应 VSCode 运行的特定架构。为此,我想将架构设为uname --m(例如“aarch64”或“amd64”)。我的目标是将 的输出uname插入到这样的环境变量中

"version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "cmake",
        "args": [
            "-DMYLIB_INCLUDE_DIR=$MYLIB/include",
            "-DMYLIB_LIBRARY=$MYLIB/lib"
        ],
        "options": {
            "env": {
                "MYLIB": "${workspaceFolder}/mylib/${command:get_arch}"
            }
        },
    }
]
Run Code Online (Sandbox Code Playgroud)

就我而言,我将有架构的特定版本mylib下mylib/aarch64,mylib/amd64,等。

到目前为止,我尝试定义get_arch在 的环境定义中使用的第二个任务MYLIB,它只是运行uname。

{
    "label": "get_arch",
    "type": "shell",
    "command": "uname --m"
}
Run Code Online (Sandbox Code Playgroud)

当然,这个任务不是一个正确的命令,所以它没有被 VSCode 检测到,我的构建任务失败了。我查看了有关变量替换的文档,但他们没有提到是否可以替换shell 命令。我想这在扩展中是可能的,但我想让事情尽可能简单。

visual-studio-code vscode-settings vscode-tasks

1
推荐指数
1
解决办法
1718
查看次数

你如何在 VsCode 中调试 Flutter?

当应用程序运行应用程序内模拟器时,如何调试他们的 Flutter 代码?

debugging visual-studio-code flutter

1
推荐指数
1
解决办法
5031
查看次数

VSCode 的“打开文件夹时运行”任务中的“打开文件夹时”是什么意思?

VSCode 去年添加了一项功能,可以在“打开文件夹时”自动运行任务。但是在使用工作区时“打开文件夹”是什么意思?

具体来说,如果你打开一个工作区,"runOn": "folderOpen"任务会运行吗?如果是这样,如何?

我之所以这么问是因为我将任务配置为自动运行,但是当我打开工作区时它没有运行。(任务在手动触发时正确运行。)

visual-studio-code vscode-tasks

1
推荐指数
1
解决办法
769
查看次数

vscode 找不到带有诗歌和 wsl 的 python

我想在 vscode 槽 WSL 中使用由诗歌“创建”的 python interperter,但正确的 python 版本没有出现在 vscode 中。

我在 WSL 终端中运行以下命令:

$ poetry shell
Spawning shell within /home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7
$ code .
Run Code Online (Sandbox Code Playgroud)

在 vscode 中发现的唯一互操作者是/usr/. 我试过手动输入 virtualenv 的路径,但没有运气。这是路径which python返回:/home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7/bin/python

python visual-studio-code python-poetry

1
推荐指数
1
解决办法
1571
查看次数

VS Code 中的 create-react-app 在 Windows 上引发未经授权的访问

当我尝试在我的 Windows 机器上创建 React 应用程序时,我不断获得未经授权的访问。我没有在 Mac 上遇到过这种行为,所以我真的不知道是什么导致了这个问题。

在 VS Code 的终端中,我运行了以下命令:

PS C:\Users\Foo_Bar\sandbox> npm install -g create-react-app
C:\Users\Foo_Bar\AppData\Roaming\npm\create-react-app -> C:\Users\Foo_Bar\AppData\Roaming\npm\node_modules\create-react-app\index.js
added 91 packages from 45 contributors in 6.923s

PS C:\Users\Foo_Bar\sandbox> create-react-app --version 
create-react-app : File C:\Users\Foo_Bar\AppData\Roaming\npm\create-react-app.ps1 ca 
nnot be loaded because running scripts is disabled on this system. For more information, see 
 about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ create-react-app --version
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\Foo_Bar\sandbox> create-react-app test-app
create-react-app : …
Run Code Online (Sandbox Code Playgroud)

npm reactjs windows-10 visual-studio-code create-react-app

1
推荐指数
1
解决办法
3455
查看次数

VSCode 无法更新扩展

我遇到VSCode了一段时间的问题,我无法检测到阻止我更新的问题Extensions

在此处输入图片说明

Failed to update 'ms-python.python'.

Failed to update 'formulahendry.code-runner'.

visual-studio-code vscode-code-runner

1
推荐指数
1
解决办法
654
查看次数

VsCode 不使用单引号格式化 TS/JS 文件

在 VS Code 的最新更新之一之后,在 Windows 中按 Ctrl+Shift+F 时,尽管我将其设置为仅使用单引号,但它会自动使用双引号而不是单引号格式化我的所有代码。

这是我的设置文件:

{
"[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.updateImportsOnFileMove.enabled": "always",
"[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
},
"atlascode.jira.workingSite": {
    "baseUrlSuffix": "atlassian.net"
},
"yaml.schemas": {
    "file:///c%3A/Users/kevin/.vscode/extensions/atlassian.atlascode-2.1.5/resources/schemas/pipelines-schema.json": "bitbucket-pipelines.yml"
},
"window.zoomLevel": -1,
"[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
},
"git.autofetch": true,
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"prettier.jsxSingleQuote": true,
"prettier.singleQuote": true
Run Code Online (Sandbox Code Playgroud)

}

还有人处理这个吗?

谢谢!!!

javascript typescript visual-studio-code prettier

1
推荐指数
1
解决办法
1703
查看次数

为什么这个正则表达式不匹配 VSCode 搜索和替换中的任何内容?

我正在使用 VSCode
在此处输入图片说明

显示我选择的搜索选项的屏幕截图: 在此处输入图片说明

这是我尝试使用的表达方式。它适用于其他地方,例如 regexr.com,但不适用于 VSCode...

font\-size\:\s{0,1}\d{2,2}px\;\s{0,1}
Run Code Online (Sandbox Code Playgroud)

这是 HTML:

https://codepen.io/JashoowellPadderssonn/pen/WNbVVEq

我还尝试禁用所有不起作用的扩展。这是我的 VSCode 设置:

https://gist.github.com/CrocodileInAWhileAlligatorLater/409f0d9d179955ff80419a8a4506a09d

css regex html-email visual-studio-code

1
推荐指数
1
解决办法
1521
查看次数

Visual Studio Code (VSCode) 如何知道 ~/.config/fish/config.fish 中设置的环境变量?

环境:

  • macOS Catalina
  • 视觉工作室代码
  • 鱼壳

我使用 fish 作为默认 shell,并且几乎每个环境变量 include$PATH都设置在~/.config/fish/config.fish(~/.bash_profile在 bash 中) 内。当我使用 Visual Studio Code 时,它​​知道设置的环境变量,~/.config/fish/config.fish尽管它的父进程是/sbin/launchd,而不是fish。这是怎么发生的?

macos environment-variables visual-studio-code

1
推荐指数
1
解决办法
1543
查看次数

VS Code IntelliSense 不适用于 Unity。为什么?

VS Code IntelliSense 不适用于 Unity。为什么?

我在 VS Code 中使用 Unity。当我打字时,我没有得到任何与 Unity 相关的建议。例如,gameObject一旦我输入,我就没有得到建议this.:

在此处输入图片说明

另一个例子是我不能去MonoBehaviour定义:

在此处输入图片说明 在此处输入图片说明

我看到了这个问题。因此,我检查了答案中推荐的所有扩展是否已安装:

在此处输入图片说明

扩展安装没有帮助。有人可以帮忙解决这个问题吗?

我正在使用Unity 2019.3.2f1。

如果在 Unity Editor 中,我转到Window - Package Manager - 搜索Visual Studio Code Editor我看到它在那里:

在此处输入图片说明

实际上我什至看不到System的定义。所以,我认为 VS Code 方面应该有问题:

在此处输入图片说明

另外,我跟着视频。它没有帮助。视频下方有评论:

对于仍然无法使自动完成工作的任何人,请尝试安装“.net framework 4.7.1 developer pack”。

就我而言,我使用的是 Unity 2019.1.2,并且我安装了 dotnet core 2.2,它带有“.net framework 4.7.2.”。显然 Unity 2019.1.2 需要框架 4.7.1。您可以通过检查 Assembly-CSharp.csproj 文件找到所需的 .net 框架版本

我遵循了评论建议。我检查了TargetFrameworkVersion. 它是4.7.1。所以,我下载了4.7.1. …

c# intellisense unity-game-engine visual-studio-code

1
推荐指数
1
解决办法
6318
查看次数