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

时间:2020-05-06 01:41:55

标签: powershell visual-c++ visual-studio-code cmd cl

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

1 个答案:

答案 0 :(得分:1)

要使Visual Studio Code的集成终端像Visual Studio 2019附带的Developer PowerShell for VS 2019控制台一样工作,请将以下内容添加到Visual Studio Code settings.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,然后导入模块并从该模块调用功能。

我已从以下快捷方式文件(*.lnk)的“属性”对话框中获取(并改编了)这些命令的详细信息(视Visual Studio版本而定):

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