[PSS 2018][Bug] Module Cache skipping modules

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

[PSS 2018][Bug] Module Cache skipping modules

Post by Bosparan »

PSS Version: 2018 5.5.155x64
OS Version: Windows 10 x64 1803
WMF Version: 5.1

Impact: High

Description:
On new installations, PowerShell Studio will build the module cache and declare that action finished.
However, it will not cache any content from any of my modules, leaving me without any Primal Sense on my most critical commands.
On existing installations, it will not update the cache anymore.
Impacted Modules:
- PSFramework
- PSUtil (Depends on PSFramework)
- PSModuleDevelopment (Depends on PSFramework)
I'm assuming the CacheBuilder has problems with loading PSFramework, however I was unable to find any relevant logs.

Reproducibility:
Install the PSFramework Module and have PowerShell Studio refresh the cache.
Once done, test Primal Sense, for example for the command Write-PSFMessage.

Workarounds / Mitigations:
I have built command that will calculate the cache entries for me.
Using that command I can successfully inject up-to-date values into the Primal Sense.
Once done this way, it will even pick up Enumerated Types for Primal Sense as input options, so the core Application has no issues working with it.
Code: [Select all] [Expand/Collapse] [Download] (New-PSSModuleCache.ps1)
  1. function New-PSSModuleCache
  2. {
  3.                [CmdletBinding()]
  4.                param (
  5.                               [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
  6.                               [System.Management.Automation.PSModuleInfo[]]
  7.                               $Module
  8.                )
  9.                
  10.                begin
  11.                {
  12.                               $common = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'InformationAction', 'ErrorVariable', 'WarningVariable', 'InformationVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable'
  13.                }
  14.                process
  15.                {
  16.                               foreach ($moduleItem in $Module)
  17.                               {
  18.                                              $ctext = @()
  19.                                              $mtext = '{0}|{1}|' -f $moduleItem.Name, $moduleItem.Version.ToString()
  20.                                              $atext = @()
  21.                                              
  22.                                              # Write Header
  23.                                              $ctext += '[Module]'
  24.                                              $ctext += '{0}|{1}|{2}' -f $moduleItem.Name, $moduleItem.Version.ToString(), $moduleItem.Description
  25.                                              
  26.                                              $commands = $moduleItem.ExportedCommands.Values
  27.                                              foreach ($command in $commands)
  28.                                              {
  29.                                                             if ($command.CommandType -like "Alias")
  30.                                                             {
  31.                                                                            $atext += '{0} {1}' -f $command.Name, $command.ResolvedCommand.Name
  32.                                                                            continue
  33.                                                             }
  34.                                                             $help = Get-Help -Name $command.Name
  35.                                                             $ctext += '[Command]'
  36.                                                             $ctext += '{0}|{1}|C' -f $command.CommandType, $command.Name
  37.                                                             $ctext += ''
  38.                                                             $ctext += $help.Synopsis
  39.                                                             $ctext += '[Syntax]'
  40.                                                             foreach ($set in $command.ParameterSets)
  41.                                                             {
  42.                                                                            $ctext += '{0}|{1} {2}' -f $set.Name, $command.Name, $set.ToString()
  43.                                                             }
  44.                                                             $ctext += '[Outputs]'
  45.                                                             foreach ($set in $command.ParameterSets)
  46.                                                             {
  47.                                                                            if ($command.OutputType)
  48.                                                                            {
  49.                                                                                           $ctext += '{0}|{1}' -f $set.Name, $command.OutputType[0].Type.ToString()
  50.                                                                            }
  51.                                                                            else { $ctext += '{0}|System.Management.Automation.PSObject[]' -f $set.Name }
  52.                                                             }
  53.                                                             $ctext += '[Parameters]'
  54.                                                             foreach ($parameter in $command.Parameters.Values)
  55.                                                             {
  56.                                                                            if ($parameter.Name -in $common) { continue }
  57.                                                                            $ctext += '{0}|{1}|' -f $parameter.Name, $parameter.ParameterType
  58.                                                             }
  59.                                              }
  60.                                              
  61.                                              [pscustomobject]@{
  62.                                                             PSTypeName = 'PSS.Module.Cache'
  63.                                                             Module    = $mtext
  64.                                                             Aliases    = $atext -join "`n"
  65.                                                             Commands   = $ctext -join "`n"
  66.                                              }
  67.                               }
  68.                }
  69. }
Notes:
This issue also existed in the previous version.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: [PSS 2018][Bug] Module Cache skipping modules

Post by Alexander Riedel »

It is generally not a good idea to mess with the cache files manually. Please don't make any assumptions, talk to us first.

Where is this module from? I get the impression it is developed by you?
Where is it installed (in $PSModulePath?)
Does it show up in Get-Module -listavailable?
Have you tried importing the module with the import function in the Cache Editor?
Alexander Riedel
SAPIEN Technologies, Inc.
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

Re: [PSS 2018][Bug] Module Cache skipping modules

Post by Bosparan »

Hi Alexander,

- The module is developed by me, it is my main scripting framework and literally every single module and script I build uses it
- It's installed in the $PSModulepath (the default Program Files path for modules, specifically)
- Yes, it shows up with Get-Module -ListAvailable. It imports and executes perfectly fine as well.
- Yes I have tried importing it using the Import function in the cache editor, for no improvement
- In unedited original cache files for commands/cmdlets, all affected modules are listed with zero commands. (Sorry, kind of should have thought to mention that right away). They still are after explicit import. If I remove them, then do the import it will again show up, but still without commands :(

Cheers,
Fred
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: [PSS 2018][Bug] Module Cache skipping modules

Post by Alexander Riedel »

Ok, can you email me that module?
Alexander Riedel
SAPIEN Technologies, Inc.
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

Re: [PSS 2018][Bug] Module Cache skipping modules

Post by Bosparan »

Sure, if you've got me your email address.
Alternatively you could just install it from the gallery (that's where I deploy mine from):

Install-Module PSFramework

In case all three are needed to reproduce this, also:

Install-Module PSUtil
Install-Module PSModuleDevelopment

Other than those modules, the computer was a clean install, no extra tools installed yet.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: [PSS 2018][Bug] Module Cache skipping modules

Post by Alexander Riedel »

I'll get it from the gallery, but for future reference, under my avatar, there is a contact icon. It has an email option :D
Alexander Riedel
SAPIEN Technologies, Inc.
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

Re: [PSS 2018][Bug] Module Cache skipping modules

Post by Bosparan »

Merci :)
As for that button: I only get offered to write a DM (which doesn't support attachments). :D
I'm assuming that access to email links is restricted to privileged forums users (would be a bit of a problem if regular users could see the email address of other users)
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: [PSS 2018][Bug] Module Cache skipping modules

Post by Alexander Riedel »

Doh! Sorry, I assumed that fancy MVP avatar allowed you access to that. Never mind... There is always support@sapien.com if needed :D
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.