共用方式為


如何在 powershell.exe 以外的 netfx 主機中使用 Appx 模組

Appx PowerShell 模組已複位為 netstandard2.0,以確保其與 .netcore 的未來保持一致,同時繼續支援 .netfx。 重新定位的結果是造成重大變更,這表示 Appx PS Module Cmdlet(在 netfx 執行階段下運行時)無法在從 powershell.exe 以外的程序中運行。

有兩種方式可以減輕這項變更,以在 powershell.exe 以外的 netfx 主機中使用 Appx 模組。

選項 1: 想要在 netfx 運行時間環境中使用 Appx PS 模組 Cmdlet 的每個進程(非powershell.exe)都必須將下列 4 個運行時間元件新增至該進程可存取的位置。 這通常是藉由將這四個運行時間元件放在進程的 *.exe 檔案旁邊來完成。

  • System.Memory.dll (4.0.1.0, netstd, v2.0)
  • System.Numerics.Vectors.dll (4.1.4.0, netstd, v2.0)
  • System.Runtime.CompilerServices.Unsafe.dll (4.0.4.0, netfx, v4.0)
  • System.Security.Principal.Windows.dll (4.1.1.0, netfx, v4.0)

這四個運行時間元件可以在各自的 NuGet 套件 (4.5.0 版) 中找到。

選項 2: 將進程的運行時間環境從 netfx 複位為 netcore。