我已经安装了用于VS的最新版本POSH工具(3.0.375在写作时)在Visual Studio 2015年社区为VS POSH工具 - 无法调试脚本/在Visual Studio模块
创建后任何PowerShell脚本/模块项目,我无法在Visual Studio中运行或调试它。在没有打开文件的情况下运行它只会导致脚本/模块“生成”。
------ Build started: Project: PowerShellModuleProject1, Configuration: Debug Any CPU ------
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
我也在调试窗格中得到这个。
C:\PowerShellModuleProject1\PowerShellModuleProject1.psd1
The program 'PowerShellModuleProject1.psd1: PowerShell Script' has exited with code 0 (0x0).
使用打开的选项卡运行它,只需在PowerShell ISE中打开该文件即可。试图运行项目中提供的功能给我通常的错误:
Get-Function : The term 'Get-Function' 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 line:1 char:1
+ Get-Function
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Function:String) [], CommandNotFou
ndException
+ FullyQualifiedErrorId : CommandNotFoundException
卸载并重新安装扩展没有影响。我仍然得到同样的东西。
这是在Windows 10 Home,VS社区2015(更新2)上运行最新版本的VS的扩展库中的VSH Tools。
更新: 不知何故,纯脚本正在工作,但模块不是。我在调试输出中发现了这个错误。
PS C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE> C:\PowerShellModuleProject1\PowerShellModuleProject1.psm1
[ERROR] Program 'PowerShellModuleProject1.psm1' failed to run: Application not foundAt
[ERROR] line:1 char:1
[ERROR] + . 'C:\PowerShellModuleProject1\PowerShellModuleProject1.psm1'
[ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
[ERROR] At line:1 char:1
[ERROR] + . 'C:\PowerShellModuleProject1\PowerShellModuleProject1.psm1'
[ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR] + CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedEx
[ERROR] ception
[ERROR] + FullyQualifiedErrorId : NativeCommandFailed
[ERROR]