PowerShell / PowerShell/vscode-powershell

Extension preloads DLLs even tho the modules are not used

Aperta
#3,912 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area-Symbols & References Issue-Bug
Lingua principale
TypeScript
Stelle
1.9k
Fork
548
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Prerequisites
  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
Summary

I am not sure if this is something that can be fixed, but it's been showing up for me very often, a lot for PowerShell 7.3, never for PowerShell 5.1 and sometimes for newer PowerShell versions.

I develop my modules in VSCode. Once I'm happy with the module that it works enough I combine everything, including DLLs, and push it to standard PowerShell module folders so my apps can use it. This is my so-called "production" version that I know works correctly and can be publish to psgallery. But then I continue working with the non-production version in VSCode.

Whenever I open PowerShell 7 and do Import-Module .\Mymodule.psd1 -Force it claims the DLLs are already loaded.

image

Of course the warning comes from my PSM1 where I explicitly detect the error when I try to do Add-Type and prevent it.

I tried tracking it - Whenever I open PowerShell 7 (doesn't seem to show up in 5.1) it seems that it already preloads DLL's. I can see this with:

[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted 

It doesn't happen all the time, but enough time for me to notice. Those DLL's have now loaded

image

But the module itself did not:

image

My understanding is - it happens when I switch between files (just by reading them), not even running and loads DLL's in the background making a problem for development (assuming that I would like to change DLL version for example). So my guess is VSCode PowerShell wants to help me - but at the same time it impacts module development.

While I can deal with it internally I'm guessing a lot of other people may not be as happy.

PowerShell Version
Name                           Value
----                           -----
PSVersion                      7.3.0-preview.3
PSEdition                      Core
GitCommitId                    7.3.0-preview.3
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visual Studio Code Version
1.66.1
8dfae7a5cd50421d10cd99cb873990460525a898
x64
Extension Version
ms-vscode.?[7mpowershell?[0m@2021.12.0
ms-vscode.?[7mpowershell?[0m-preview@2022.3.1
tobysmith568.run-in-?[7mpowershell?[0m@1.1.1
TylerLeonhardt.vscode-inline-values-?[7mpowershell?[0m@0.0.5
Steps to Reproduce

As described above.

Visuals

No response

Logs

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Non vengono indicati file, test o punti di ingresso. Riproduci il problema aprendo PowerShell 7, passando da un file di modulo all'altro, esaminando gli assembly caricati con il comando fornito e importando il modulo; il lavoro è concluso quando hai identificato perché le DLLs inutilizzate vengono precaricate e hai impedito questo comportamento senza compromettere il supporto dei moduli.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell, typescript, vscode
Ambito
developer-experience, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.