Open happywino opened 5 years ago
Can you report the output of the following in the Integrated Console:
Import-Module PSScriptAnalyzer -PassThru
gmo -list PSScriptAnalyzer
gci ~\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules
$env:PSModulePath
PS C:\Users\ad_jcphilli> Import-Module PSScriptAnalyzer -PassThru
Import-Module : The specified module 'PSScriptAnalyzer' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ Import-Module PSScriptAnalyzer -PassThru
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (PSScriptAnalyzer:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\Users\ad_jcphilli> gmo -list PSScriptAnalyzer
PS C:\Users\ad_jcphilli> gci ~\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules
Directory: C:\Users\ad_jcphilli\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 6/17/2019 9:32 AM docs
d---- 6/17/2019 9:32 AM Plaster
d---- 6/17/2019 9:32 AM PowerShellEditorServices
d---- 6/17/2019 9:32 AM PowerShellEditorServices.VSCode
d---- 6/17/2019 9:32 AM PSScriptAnalyzer
-a--- 6/17/2019 9:32 AM 370 README.md
PS C:\Users\ad_jcphilli> $env:PSModulePath
C:\Users\ad_jcphilli\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\;C:\Program Files (x86)\Microsoft SQL Server\120\Tool
s\PowerShell\Modules\;C:\Program Files\Common Files\Skype for Business Server 2015\Modules\;C:\Users\ad_jcphilli\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules
PS C:\Users\ad_jcphilli>
Hmmm that's odd; the shipped PSScriptAnalyzer seems to be there, and that directory is on the path, but it's not available for some reason.
Maybe try:
Import-Module C:\Users\ad_jcphilli\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules\PSScriptAnalyzer -PassThru
And let us know what the output is
PS C:\Users\ad_jcphilli> Import-Module C:\Users\ad_jcphilli.vscode\extensions\ms-vscode.powershell-2019.5.0\modules\PSScriptAnalyzer -PassThru Import-Module : The specified module 'C:\Users\ad_jcphilli.vscode\extensions\ms-vscode.powershell-2019.5.0\modules\PSScriptAnalyzer' was not loaded because no valid module file was found in any module directory. At line:1 char:1
+ CategoryInfo : ResourceUnavailable: (C:\Users\ad_jcp...SScriptAnalyzer:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
The contents of "C:\Users\ad_jcphilli.vscode\extensions\ms-vscode.powershell-2019.5.0\modules\PSScriptAnalyzer" is a single folder named "1.18.0", is that expected?
is a single folder named "1.18.0", is that expected?
Yes. This is expected. This is the structure of how PowerShellGet installs modules:
...
/ModuleName/VersionNumber/MyModule.psd1
...
However... @rjmholt and I learned that support for this version number part didn't come until v5.0... and since you're on v4, it doesn't work.
We will need to restructure our build logic here to move the contents of the VersionNumber
folder under the ModuleName
folder. That way the new layout will look like:
...
ModuleName/ModuleName.psd1
...
If you have any interest in contributing to the project, this change would be pure PowerShell and pretty straightforward. Otherwise we will get to it as soon as we can!
Just so I've written in down for myself, this change only needs to go in the legacy/1.x
branch
I'd like to pick this one up :)
Awesome! Let me know if anything is not clear.
I should note that this fix will require to you verify your fix on PowerShell v4 if you can...
Since this fix is for PowerShell v4 and v3 as well, you should work off of the legacy/1.x
branch instead of the master
branch.
When you clone both vscode-powershell
and PowerShellEditorServices
make sure you run:
git checkout legacy/1.x
in each folder to work off of that code.
Success here is: "I can format my scripts when using PowerShell v4 with the PowerShell extension."
Thanks for the clear instructions! Verifying on PowerShell v3 and v4 is not a problem, I can spin up VM's for that.
Issue Description
Whenever I try to format code, either from the context menu or via Ctrl-K Ctrl-F, the extension crashes, even on a file only containing "Import-Module ActiveDirectory". The log contains an entry "Exception: PSScriptAnalyzer cannot be imported, AnalysisService will be disabled", should I be installing that or is it expected to be installed by the extension?
Attached Logs
EditorServices.log vscode-powershell.log
Environment Information
Visual Studio Code
PowerShell Information
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
|Extension|Author|Version| |---|---|---| |gitlens|eamodio|9.8.2| |powershell|ms-vscode|2019.5.0|