Integrated PSScriptAnalyzer Nonethless Does Not Provide Cursor Hover Warnings or Quick Fix Action Light Bulbs

Issue #170 new
Nick De Lancie created an issue

For VS Community 2019 v. 16.2.3 (and prior versions) | PoshTools v. 4.9.0 (not Pro) (and prior versions) | $PSVersionTable output at end

Even though (1) the PSScriptAnalyzer module (v. 1.18.1) is installed in C:\Program Files\WindowsPowerShell\Modules (such that Invoke-ScriptAnalyzer can be run from--and works in--the PowerShell Interactive Window); and (2) in Visual Studio Tools > Options > PowerShell Tools > General, Script Analyzer is set to True (the Script Analyzer Setting is left blank so the default setting will be used), cursor hover warnings and no Quick Fix action light bulbs (with suggested fixes) appear in the VS code editor for lines that Invoke-ScriptAnalyzer flags in the PowerShell Interactive Window as having possible issues.

The Posh Tools documentation for PSScriptAnalyzer (https://docs.poshtools.com/powershell-tools-documentation/script-analysis) indicates that 1 and 2 above are satisfied, the offending code line should show as a tagged region with the warning displayed on cursor hover, and the Quick Fix light bulb should appear and offer correction.

Am I missing something here to get this functionality?

Please advise.

Thanks, Nick

\$PSVersionTable:

Name                                      Value
----                                          -----
PSVersion                                5.1.15063.1805
PSEdition                                 Desktop
PSCompatibleVersions            {1.0, 2.0, 3.0, 4.0...}
BuildVersion                            10.0.15063.1805
CLRVersion                              4.0.30319.42000
WSManStackVersion               3.0
PSRemotingProtocolVersion   2.3
SerializationVersion                 1.1.0.1

Comments (3)

  1. Adam Driscoll

    I’m going to have to put some more logging in here because I’m seeing this work in my environment. I have the same versions of VS and PSScriptAnalyzer installed and I see the quick fix and the warnings in the editor.

    After I release the next version, I’ll ping this issue to see if you can gather some more diagnostics.

  2. Anthony Missico Account Deactivated

    I am having the same problem; however, it works on one computer and doesn’t work on another. Same VS and PowerShellTools versions. OS is 10 on working and 2012 R2 on non-working.

    Partial log from failing computer where the two logs start to differ, notice the “Dte object not found.” entries.

    2019-10-21 18:44:11,165 [7] INFO PowerShellTools.HostService.ServiceCommon [(null)] - Providing $dte variable to the local runspace.
    2019-10-21 18:44:11,204 [7] INFO PowerShellTools.HostService.ServiceCommon [(null)] - Dte object not found.
    2019-10-21 18:44:11,270 [1] INFO PowerShellTools.PowerShellToolsPackage [(null)] - Finished opening PowerShell host connection
    2019-10-21 18:44:11,278 [7] INFO PowerShellTools.HostService.ServiceCommon [(null)] - Setting execution policy
    2019-10-21 18:44:11,311 [7] INFO PowerShellTools.HostService.ServiceCommon [(null)] - Providing $dte variable to the local runspace.
    2019-10-21 18:44:11,335 [7] INFO PowerShellTools.HostService.ServiceCommon [(null)] - Dte object not found.
    2019-10-21 18:44:11,647 [1] INFO PowerShellTools.PowerShellToolsPackage [(null)] - Initializing IntelliSense
    2019-10-21 18:44:11,780 [1] INFO PowerShellTools.PowerShellToolsPackage [(null)] - Debugger is ready
    2019-10-21 18:44:11,783 [1] INFO PowerShellTools.PowerShellToolsPackage [(null)] - Loading profiles
    2019-10-21 18:44:11,784 [5] INFO PowerShellTools.HostService.ServiceCommon [(null)] - Checking runspace availability: Available
    2019-10-21 18:44:11,788 [4] INFO PowerShellTools.HostService.ServiceCommon [(null)] - Loading PowerShell Profiles
    2019-10-21 18:44:11,873 [4] INFO PowerShellTools.HostService.ServiceCommon [(null)] - PowershellHostService: A pipeline is already running. Concurrent SessionStateProxy method calls are not allowed.
    at System.Management.Automation.Runspaces.RunspaceBase.DoConcurrentCheckAndMarkSessionStateProxyCallInProgress()
    at System.Management.Automation.Runspaces.RunspaceBase.get_PSVariable()
    at PowerShellTools.HostService.ServiceManagement.Debugging.PowerShellDebuggingService.LoadProfiles()
    at SyncInvokeLoadProfiles(Object , Object[] , Object[] )
    at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
    at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
    at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
    2019-10-21 18:44:11,944 [1] ERROR PowerShellTools.PowerShellToolsPackage [(null)] - Failed to initialize package.
    System.ServiceModel.FaultException: There is a problem in the PowerShell host service.

    Server stack trace:
    at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
    at PowerShellTools.Common.ServiceManagement.DebuggingContract.IPowerShellDebuggingService.LoadProfiles()
    at PowerShellTools.PowerShellToolsPackage.InitializePowerShellHost()
    at PowerShellTools.PowerShellToolsPackage.InitializeInternal()
    at PowerShellTools.PowerShellToolsPackage.<InitializeAsync>d__39.MoveNext()
    2019-10-21 18:44:23,094 [1] INFO PowerShellTools.PowerShellToolsPackage [(null)] - Set PacakgeInitialized

  3. Anthony Missico Account Deactivated

    I uninstalled the extension, cleaned out all temp files, rebooted, reinstalled extension. I got a valid and initialized $dte value. I closed Visual Studio and now I am back to “Dte object not found.”

    If you set “Reset PowerShell Session” = true, then on executing a script, the $dte is valid and initialized.


    Load Profiles on start = true

    Regardless if I have a profile file or not, the following message is displayed by Visual Studio.

    ---------------------------
    PowerShell Tools for Visual Studio Error
    ---------------------------
    Failed to initialize PowerShell Tools for Visual StudioSystem.ServiceModel.FaultException: There is a problem in the PowerShell host service.
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at PowerShellTools.Common.ServiceManagement.DebuggingContract.IPowerShellDebuggingService.LoadProfiles()
       at PowerShellTools.PowerShellToolsPackage.InitializePowerShellHost()
       at PowerShellTools.PowerShellToolsPackage.InitializeInternal()
       at PowerShellTools.PowerShellToolsPackage.<InitializeAsync>d__39.MoveNext()
    ---------------------------
    OK   
    ---------------------------
    

  4. Log in to comment