mbl-35 / wslctl

Provide a single command wslctl to create, backup and manage WSL (Windows Subsystem for Linux) instances on a windows host
0 stars 1 forks source link

Powershell module cache refresh #17

Closed mbl-35 closed 2 years ago

mbl-35 commented 2 years ago

Powershell load custom module in cache, which does not take account on module changes (e.g. version upgrade). Find a way to bypass this behavior

mbl-35 commented 2 years ago

Trying ClassLoader module. Result: sub-modules have to be loaded on each module: this result on a unknown type on class inheritance !! Leave the class on source but not using it..

mbl-35 commented 2 years ago

Stay using using module to import custom modules, but use an initial wrapper to unload modules if loaded, then start main process (bootstrap.ps1).

mbl-35 commented 2 years ago

With the last method, sometimes having this error:

Remove-Module : Aucun module n'a été supprimé. Vérifiez que la spécification des modules à supprimer est correcte et que ces modules existent dans l'instance d'exécution.
Au caractère D:\project-workspaces\github\wslctl\bin\wslctl.ps1:36 : 9
+         Remove-Module $_.Name -Force
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Remove-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_NoModulesRemoved,Microsoft.PowerShell.Commands.RemoveModuleCommand

part of code:

Get-Module | ForEach-Object {
    if ($myModules.contains($_.Name)){
        Write-Verbose "removing: $_.Name"
        Remove-Module $_.Name -Force
    }
}

To be investigate ...