繁体   English   中英

有没有办法将 VS 2019 的 Developer Powershell 添加为 VSCode 中的集成终端?

[英]Is there a way to add the Developer Powershell for VS 2019 as an integrated terminal in VSCode?

我正在开发一个需要我使用 MSVC 编译 C++ 代码的项目,但我主要使用 VSCode。 因此,我想知道是否有办法将 Developer Powershell 添加为集成终端,这样我就可以在不需要打开辅助终端的情况下进行编译。 我想从 Developer PS 本身打开 VSCode,但由于这主要是一个临时项目,它似乎有很多重复的工作。 我尝试使用 VSCode 的Shell launcher扩展,但它不起作用。 有什么我可以做的吗?

要使 Visual Studio Code 的集成终端像 Visual Studio 2019 附带Developer PowerShell for VS 2019 ,请将以下内容添加到您的 Visual Studio Code settings.json中。json 文件( > Preferences: Open Settings (JSON) ):

"terminal.integrated.shell.windows": "C:/Windows/SysWOW64/WindowsPowerShell/v1.0/powershell.exe"

"terminal.integrated.shellArgs.windows": "-noe -c Import-Module 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll'; Enter-VsDevShell ed9e071d"

请注意,启动了32 位版本的 PowerShell,然后导入模块并从该模块调用 function。

我已从以下快捷方式文件 ( *.lnk ) 的“属性”对话框中获取(并调整了)命令 - 其详细信息可能因 Visual Studio 版本而异:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\Developer PowerShell for VS 2019.lnk

mklement0 答案的一个变体是在 Visual Studio Code settings.json中使用terminal.integrated.profiles.windows ,如下所示:

    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell",
            "path": "{env:windir}\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe",
            "args": [
                "-noe",
                "-c",
                "&{Import-Module 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll'; Enter-VsDevShell 7068d947}"
            ]
        }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM