问题描述
我正在开发一个项目,该项目需要我使用MSVC编译C ++代码,但我主要使用VSCode.因此,我想知道是否有办法将Developer Powershell添加为集成终端,这样我就可以在无需打开辅助终端的情况下进行编译.我本来只是想从Developer PS本身打开VSCode,但是由于这主要是一个临时项目,因此似乎需要大量重复工作.我尝试对VSCode使用 Shell启动器
扩展名,但是没有用.我有什么可以做的吗?
I'm working on a project that requires me to compile C++ code using MSVC, but I am working mostly with VSCode. As such, I was wondering if there is a way for me to add the Developer Powershell as an integrated terminal, so that I can compile without needing a secondary terminal open. I thought of just opening VSCode from the Developer PS itself, but since this is mostly a temporary project it seemed like a lot of repetitive work. I tried using the Shell launcher
extension for VSCode but it didn't work. Is there anything I can do?
推荐答案
要使Visual Studio Code的集成终端像Visual Studio 2019随附的 Developer PowerShell for VS 2019
控制台一样,请添加以下内容到您的Visual Studio Code settings.json
文件(>首选项:打开设置(JSON)
):
To make Visual Studio Code's integrated terminal act like the Developer PowerShell for VS 2019
console that comes with Visual Studio 2019, add the following to your Visual Studio Code settings.json
file (> 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,然后导入模块并从该模块调用函数.
Note that a 32-bit version of PowerShell is started, followed by import of a module and a call to a function from that module.
我从以下快捷方式文件( *.lnk
)的属性"对话框中获取了(并改编了)这些命令的详细信息(视Visual Studio版本而定):
I've taken (and adapted) the commands - whose details may differ depending on the Visual Studio version - from the Properties dialog of the following shortcut file (*.lnk
):
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\Developer PowerShell for VS 2019.lnk
这篇关于有没有一种方法可以将VS 2019的Developer Powershell添加为VSCode中的集成终端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!