[PSS 2018][Bug] Module Cache skipping modules

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
Bosparan
Posts: 282
Joined: Sun Mar 03, 2013 12:45 pm

[PSS 2018][Bug] Module Cache skipping modules

Post by Bosparan » Fri Oct 12, 2018 12:59 am

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.
  1. function New-PSSModuleCache
  2.  
  3. {
  4.  
  5.                [CmdletBinding()]
  6.  
  7.                param (
  8.  
  9.                               [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
  10.  
  11.                               [System.Management.Automation.PSModuleInfo[]]
  12.  
  13.                               $Module
  14.  
  15.                )
  16.  
  17.                
  18.  
  19.                begin
  20.  
  21.                {
  22.  
  23.                               $common = 'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'InformationAction', 'ErrorVariable', 'WarningVariable', 'InformationVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable'
  24.  
  25.                }
  26.  
  27.                process
  28.  
  29.                {
  30.  
  31.                               foreach ($moduleItem in $Module)
  32.  
  33.                               {
  34.  
  35.                                              $ctext = @()
  36.  
  37.                                              $mtext = '{0}|{1}|' -f $moduleItem.Name, $moduleItem.Version.ToString()
  38.  
  39.                                              $atext = @()
  40.  
  41.                                              
  42.  
  43.                                              # Write Header
  44.  
  45.                                              $ctext += '[Module]'
  46.  
  47.                                              $ctext += '{0}|{1}|{2}' -f $moduleItem.Name, $moduleItem.Version.ToString(), $moduleItem.Description
  48.  
  49.                                              
  50.  
  51.                                              $commands = $moduleItem.ExportedCommands.Values
  52.  
  53.                                              foreach ($command in $commands)
  54.  
  55.                                              {
  56.  
  57.                                                             if ($command.CommandType -like "Alias")
  58.  
  59.                                                             {
  60.  
  61.                                                                            $atext += '{0} {1}' -f $command.Name, $command.ResolvedCommand.Name
  62.  
  63.                                                                            continue
  64.  
  65.                                                             }
  66.  
  67.                                                             $help = Get-Help -Name $command.Name
  68.  
  69.                                                             $ctext += '[Command]'
  70.  
  71.                                                             $ctext += '{0}|{1}|C' -f $command.CommandType, $command.Name
  72.  
  73.                                                             $ctext += ''
  74.  
  75.                                                             $ctext += $help.Synopsis
  76.  
  77.                                                             $ctext += '[Syntax]'
  78.  
  79.                                                             foreach ($set in $command.ParameterSets)
  80.  
  81.                                                             {
  82.  
  83.                                                                            $ctext += '{0}|{1} {2}' -f $set.Name, $command.Name, $set.ToString()
  84.  
  85.                                                             }
  86.  
  87.                                                             $ctext += '[Outputs]'
  88.  
  89.                                                             foreach ($set in $command.ParameterSets)
  90.  
  91.                                                             {
  92.  
  93.                                                                            if ($command.OutputType)
  94.  
  95.                                                                            {
  96.  
  97.                                                                                           $ctext += '{0}|{1}' -f $set.Name, $command.OutputType[0].Type.ToString()
  98.  
  99.                                                                            }
  100.  
  101.                                                                            else { $ctext += '{0}|System.Management.Automation.PSObject[]' -f $set.Name }
  102.  
  103.                                                             }
  104.  
  105.                                                             $ctext += '[Parameters]'
  106.  
  107.                                                             foreach ($parameter in $command.Parameters.Values)
  108.  
  109.                                                             {
  110.  
  111.                                                                            if ($parameter.Name -in $common) { continue }
  112.  
  113.                                                                            $ctext += '{0}|{1}|' -f $parameter.Name, $parameter.ParameterType
  114.  
  115.                                                             }
  116.  
  117.                                              }
  118.  
  119.                                              
  120.  
  121.                                              [pscustomobject]@{
  122.  
  123.                                                             PSTypeName = 'PSS.Module.Cache'
  124.  
  125.                                                             Module    = $mtext
  126.  
  127.                                                             Aliases    = $atext -join "`n"
  128.  
  129.                                                             Commands   = $ctext -join "`n"
  130.  
  131.                                              }
  132.  
  133.                               }
  134.  
  135.                }
  136.  
  137. }
Notes:
This issue also existed in the previous version.

User avatar
Alexander Riedel
Posts: 6727
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Fri Oct 12, 2018 6:54 am

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.

User avatar
Bosparan
Posts: 282
Joined: Sun Mar 03, 2013 12:45 pm

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

Post by Bosparan » Fri Oct 12, 2018 8:50 am

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: 6727
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Fri Oct 12, 2018 9:06 am

Ok, can you email me that module?
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
Bosparan
Posts: 282
Joined: Sun Mar 03, 2013 12:45 pm

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

Post by Bosparan » Fri Oct 12, 2018 11:34 am

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: 6727
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Fri Oct 12, 2018 3:50 pm

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.

User avatar
Bosparan
Posts: 282
Joined: Sun Mar 03, 2013 12:45 pm

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

Post by Bosparan » Fri Oct 12, 2018 11:49 pm

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: 6727
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Sat Oct 13, 2018 6:56 am

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.