启动Visual Studio for Mac时加载PowerShell模块以进行调试

启动Visual Studio for Mac时加载PowerShell模块以进行调试,powershell,visual-studio-2017,visual-studio-mac,powershell-v6.0,Powershell,Visual Studio 2017,Visual Studio Mac,Powershell V6.0,我正在使用Visual Studio for Mac(7.7.2;build 21)使用C#创建PowerShell提供程序 我希望IDE加载PowerShell进行调试 项目的运行配置: 启动外部项目:/usr/local/bin/pwsh 参数:-NoProfile-NoExit-File“/InstallProvider.ps1” InstallProvider.ps1: Import-Module "./PsMyModule.psd1" -Force -Verbose PsMyMo

我正在使用Visual Studio for Mac(7.7.2;build 21)使用C#创建PowerShell提供程序

我希望IDE加载PowerShell进行调试

项目的运行配置:

  • 启动外部项目:
    /usr/local/bin/pwsh
  • 参数:
    -NoProfile-NoExit-File“/InstallProvider.ps1”
InstallProvider.ps1

Import-Module "./PsMyModule.psd1" -Force -Verbose
PsMyModule.psd1

@{
  # Script module or binary module file associated with this manifest.
  RootModule = 'PsMyModule.dll'
}
这两个文件(
ps1
psd1
)都标记为
复制到输出

在调试模式下运行项目时,出现以下错误:

参数“./InstallProvider.ps1”未被识别为的名称 脚本文件。检查名称的拼写或路径是否正确 包括,请验证路径是否正确,然后重试

用法:pwsh[.exe][-File][args]] [-Command{-|[-args] | [] } ] [-ConfigurationName][-EncodedCommand] [-ExecutionPolicy][-InputFormat{Text | XML}] [-交互式][NoExit][NoLogo][非交互式][NoProfile] [-OutputFormat{Text | XML}][-Version][-WindowStyle] [-WorkingDirectory]

   pwsh[.exe] -h | -Help | -? | /?
PowerShell联机帮助

所有参数都不区分大小写。申请被终止 未知信号:当前平台不支持此值。 参数名称:值实际值为64

然而,当我从终端运行
pwsh
时,它按预期加载的模块:

~/.../bin/Debug/netstandard2.0$ pwsh -NoExit -File "./InstallProvider.ps1"
PowerShell 6.1.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

VERBOSE: Loading module from path '/Users/[user]/Projects/Visual Studio 2017/PsMyModule/bin/Debug/netstandard2.0/PsMyModule.psd1'.
VERBOSE: Loading module from path '/Users/[user]/Projects/Visual Studio 2017/PsMyModule/bin/Debug/netstandard2.0/PsMyModule.dll'.
VERBOSE: Loading module from path 'C:\Users\XXX\source\repos\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0\FooModule.psd1'.
VERBOSE: Loading module from path 'C:\Users\XXX\source\repos\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0\FooModule.dll'.
PS C:\Users\XXX\source\repos\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0>
这些变体都不起作用:

  • -文件“\InstallProvider.ps1”
  • -File InstallProvider.ps1
  • -文件“/InstallProvider.ps1”
**编辑0**

我将
文件
参数更改为
“/Users/[user]/Projects/visualstudio 2017/PsMyModule/bin/Debug/netstandard2.0/InstallProvider.ps1”

似乎没有正确解释相对路径。此外,提示
PS\>
似乎不接受输入

**/编辑0**

**编辑1**

我在Visual Studio 2017中为Windows创建了一个类似的项目。调试设置:

它按预期加载了模块:

~/.../bin/Debug/netstandard2.0$ pwsh -NoExit -File "./InstallProvider.ps1"
PowerShell 6.1.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

VERBOSE: Loading module from path '/Users/[user]/Projects/Visual Studio 2017/PsMyModule/bin/Debug/netstandard2.0/PsMyModule.psd1'.
VERBOSE: Loading module from path '/Users/[user]/Projects/Visual Studio 2017/PsMyModule/bin/Debug/netstandard2.0/PsMyModule.dll'.
VERBOSE: Loading module from path 'C:\Users\XXX\source\repos\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0\FooModule.psd1'.
VERBOSE: Loading module from path 'C:\Users\XXX\source\repos\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0\FooModule.dll'.
PS C:\Users\XXX\source\repos\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0>
**/编辑1**


我错过了什么?OS X版本有什么不同?

您需要将项目目标目录指定为“在目录中运行”,因为您没有启动项目,工作环境将基于VS4M的环境,并且shell不在项目调试/发布目录输出中:


您尝试过ps1文件的完整路径吗?这是可行的,但是提示(
PS\>
)似乎不接受输入。我在外部控制台上运行了
并在运行|配置|默认设置中选中了
暂停控制台输出
。这是否应该打开一个新的终端窗口,然后启动
pwsh