繁体   English   中英

如何将 Developer Powershell 重新指向 2022 devenv.exe

[英]How do I repoint Developer Powershell to 2022 devenv.exe

要重现开发人员 powershell 错误,请按照以下步骤操作:

  • 卸载 Visual Studio 2019
  • 安装 Visual Studio 2022
  • 打开 Visual Studio 2022
  • 右键单击项目
  • 在菜单中单击“在终端中打开”

开发者PowerShell打开显示错误信息:



vs : The term 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Users\jdoe\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:340 char:2
+     vs "C:\EDW\My Project\My Project.sl ...
+     ~~
    + CategoryInfo          : ObjectNotFound: (C:\Program File...\IDE\devenv.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.4.4
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************

我如何解决它?

可能(并且希望)有更好的解决方案,但这是一个实用的解决方案:

  • 创建目录C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7并在其中定义一个名为IDE的符号链接,以 Visual Studio 2022 中的类似目录为目标。

请注意,海拔是必需的:

$oldDir = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE'
# Adapt as needed
$newDir = 'C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\Common7\IDE'


# Create the parent dir. of the missing old dir.
$oldParentDir = New-Item -Type Directory -Force (Split-Path -Parent $oldDir) -ErrorAction Stop

# Create symlink for the last component that points to the desired dir.
New-Item -Type SymbolicLink $oldDir -Target $newDir -ErrorAction Stop

暂无
暂无

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

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