-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Appx - Import-Module: Operation is not supported on this platform. (0x80131539) #13138
Comments
@SteveL-MSFT @joeyaiello this sounds like it could be a consequence of the missing WinRT libraries (#13042). Will the Appx module maintainers will want to package the WinRT libs with their module? Even if they do, it will mean anyone using newer versions of PS on older Windows versions will be unable to use the AppX module, since that module is shipped with Windows. @carlocardella can you provide the output from |
Here you go:
|
Hmmmm, this I don't understand, as the compatible libraries should be available on the box. But it's WinRT, not NetFx, so we're probably not looking in the right place for them with our GAC logic. Or maybe the included WinRT libraries in 3.1 were forwarders all along? @adityapatwardhan can you and I talk about this one offline this week? |
@joeyaiello PowerShell is likely still loading everything as it does in 7.0, but the CoreCLR cannot consume Windows Metadata files (WinMDs) anymore. Quote from dotnet/docs#18875
|
@joeyaiello It's throwing in Edit: Oops GitHub didn't update, @daxian-dbw beat me to it 🙂 |
But as @SteveL-MSFT noted here (and @iSazonov below that), if the module author can put em back, than so can PS. My question is whether we need both of those DLLs to get this WinMD support, or if we could ship something lighter that picks up the remaining right stuff off the Windows install. Also, I'd like to spend a little time understanding .NET's decision a little better. We may be reinventing the wheel here, or they may be a larger reason they pulled support in .NET 5 that we're missing. I'll try to do a little digging this week |
That works because he's referencing the newly defined types from the package. The AppX module directly references WinRT types. This exception is at type load because of how the
I'd love to be wrong but I'm pretty sure there's nothing PowerShell can ship to make this work, other than a new version of the AppX module. |
The exception is too early in the code path for anything to be injected atm. I don't know if this would work, but it might be worth talking to the dotnet team to see if the exception can be moved to after custom assembly resolve handlers are raised. Maybe if that was done the handler could point the resolution request to the new managed lib. At a glance it looks like the signatures should match. I'm guessing that would be flimsy at absolute best but maybe that sparks an idea for them. |
Nah that's a bust. To test I manually removed the assembly ref flag for
|
I manually changed the method ref to |
It seems .Net team explicitly said that WinRT application should be recompiled in the case. So we need new version of the module. |
@iSazonov Yeah that's definitely their current stance. It was pretty easy to coerce it into working though. I think it would be moderately easy for the dotnet team to enable an application to re-add support for these assemblies. They would be able to keep actual support for winrt completely out of dotnet/runtime, but an application like PowerShell could hook it back up potentially seamlessly. Anyway that's mainly just to give @joeyaiello some ideas if he was still intending to discuss it with them. If not then yeah just ship a new version I suppose. |
I have exactly the same problem. 😭 |
can you place a download link of your package so can verify it too? |
@salyounis It was just for testing purposes, I would heavily advise against using an assembly whose metadata has been modified manually. |
We are still investigating this, but we are open to servicing this if this isn't fixed by 7.1 release. |
Per .NET team, if we retarget the Windows release to |
@SteveL-MSFT are we 100% sure they mean it'll work without recompiling? It fails at the runtime level, unless they plan on lighting up the assembly resolution logic again, this module will still need to be recompiled. |
@SeeminglyScience won't know until we try, the implication is that retargeting to the new TFM will pull in the necessary assemblies to make it work. My suspicion is that a recompilation of Appx module is required, but that will then break running in Windows PowerShell. The other option is to not mark it as Core compatible to have it go through the Windows PowerShell path. Even now, you can just |
This may already be understood so I apologize if I'm just reiterating facts y'all already know, but the point where this exception is thrown won't be affected by any additional assemblies. It's hard coded to throw at type ref resolution well before any other code runs. It's more or less the first stop in the code path. Really I'm just trying to make sure y'all aren't banking on that working, if that's already understood then 👍
I did outline another potential path that would allow host processes like PowerShell to map these older assembly references to the new library.
If those are done then compat can be kept for these modules without compromising their goal of getting the code out of I just want to make sure all the options are being considered. If y'all don't want to pursue that then 👍 |
@SeeminglyScience spoke with .NET team and based on your idea, they agreed that to maintain compatibility, they would expose both set_ and put_ accessors for WinRT microsoft/CsWinRT#402. Thanks! |
The last response from Microsoft was:
The standard work-around is to run the following command before using any cmdlets from the AppX module: Import-Module -Name Appx -UseWindowsPowerShell
Alternatively, the AppX module is compatible with PowerShell 5.1. You can launch PowerShell 5.1 by specifying its executable name: That recent comment about WinGet is not relevant to this issue. Mike |
Yeah, this isn't working for me. Every time I specify powershell.exe, even if I give the full path to it, it still gets redirected to pwsh.exe. So good to know that MS's stance is "Oopsie, we broke it three years ago. Oh well, get a new operating system." With support like that, my new OS will be Ubuntu.
@SteveL-MSFT, I want you to know that this type of "support" is exactly why I don't care to purchase from MS anymore. If something was working when the OS was shipped, but was broken later on, you should have the common decency to fix the issue for the customers you already have. Telling them to just go get a new version you do care about is one of the scummiest, greediest things I can imagine. And no, I don't mean you specifically, I mean MS as a whole. |
Super frustrating problem that still exists, and an even more frustrating Issue conclusion (Use the Feedback Hub.) It really sucks when we need to report a problem and the only mechanism Microsoft provides is via the Feedback Hub. It's impossible to get any feedback from Microsoft after doing so. It's similarly impossible to know whether others are experiencing the same issue or whether anybody has come up with a workaround. Or whether it is in fact an actual issue to begin with! |
Get-AppXPackage: The 'Get-AppXPackage' command was found in the module 'Appx', but the module could not be loaded due to the following error: [Operation is not supported on this platform. (0x80131539)]
For more information, run 'Import-Module Appx'.
PS C:\Windows\System32> Import-Module Appx
Import-Module: Operation is not supported on this platform. (0x80131539) Still seeing the issue with PowerShell 7.3.5. Solutions in thread to use the command Import-Module -Name Appx -UseWindowsPowerShell works but gives the following warning: PS C:\Windows\System32> Import-Module -Name Appx -UseWindowsPowerShell
WARNING: Module appx is loaded in Windows PowerShell using WinPSCompatSession remoting session; please note that all input and output of commands from this module will be deserialized objects. If you want to load this module into PowerShell please use 'Import-Module -SkipEditionCheck' syntax. |
Also seeing 0x80131539 on OS build 19045.3393 with ps 7.3.6. MS documentation points us here for github support so I'm not sure why it would be marked as external? |
Hit this today (7.3.6) trying to reinstall a broken Maps app with Get-Appxpackage (0x80131539) |
Still the same in 7.3.9 |
Let me attempt a pragmatic summary, as of late 2023: The problem:
Workarounds:
|
I just got a newish laptop and installed the new PS on it; while I did not run into the OP's issue as I have before with a new laptop (as noted above) I did get this:
Per this: https://learn.microsoft.com/en-us/answers/questions/295167/activedirectory-with-powershell-7-on-windows-serve looks like the built-in PS's prompt to load a new version of PS was, in fact, wrong? lol. Such a mess. Ah, that's covered above. I checked and my output was definitely per the above:
I'm not going to worry with this because the new company is on AWS, not Azure, so I can let sleeping dogs sleep.
|
Encountered a similar issue. Strangely, "...AppData\Local\Microsoft\WindowsApps" was not included in the system's PATH variable. |
@doctordns please reopen this issue and remove |
Just hit this issue trying to install the new Teams client in Windows Server 2019 and found it did not recognise MSIX files at all then I had to install the latest PowerShell then I received the error listed here but the command from @juvtib worked and then I was able to run the install so the order of commands was:
However I then received an error saying I needed a Windows Developer Licence or a sideloading policy so I went to After that I repeated the second command above and the appx package was installed. So I got there in the end but why does everything have to be made so difficult 😅 It would be nice if supported operating systems could be updated, you know as if they were supported! |
@robinwilson16 Thanks for updating the procedure. For the record, I did not invent |
I tried all the above fixes, none work. Fairly sure I don't even want or need Appx in Win10? If the canonical fix only works in win11 I am happy to get rid of Appx to get round these issues. Is that a possibility? The forced adoption of this seems to be related to every issue I've had. BTW: Recent Win10 Update completely screwed my machine with most things reporting similar errors, loads of inaccessible apps or apps reporting missing DLLs. No start menu. One fix did a forced update to PS7 (which broke even more things). Broken WSL2. At one point most apps did not work. Then those that were in the systray during the update. Tried dozens of so called PowerShell fixes, (most of which are like magic spells to me an I'm supposed to know a thing or two about computers..) Of those, most did more damage or nothing at all. The 'update' even removed the vendor supplied system restore partition! Thinking of just giving up and formatting HDD then installing Debian. I only use Windows for some CAD software that does not run on Linux and Wine is getting useful. Is all this an attempt to force the die hard 10 users to 11? My machines have rarely got virus infections but when they have they did less damage. Now, I've fixed most issues (including WSL) but the start menu missing is annoying as I have to go seek the actual .exe to run anything. Would removing appx (as this appears to be a win 11 thing) fix that? |
I'm sorry for your troubles. Based on the symptoms you describe, it sounds like you're having a more serious issue than a simple PowerShell error. And, I suggest looking for advice in a dedicated support forum or in a local repair shop. Note that AppX is just a file format (like .vhdx or .docx) which you can just ignore. There is nothing to gain by trying to remove support for AppX within Windows. Regards, |
I have same problem on |
Windows PowerShell (v5) and PowerShell Core (v6+) are unrelated. Windows PowerShell was built into Windows and works correctly with the underlying AppX module. PowerShell Core is a cross-platform version of PowerShell which tracks .NET LTS. The AppX loading issue is specific to later versions of PowerShell Core. I can't remember the exact issue anymore. But, PowerShell Core inherited this issue when there was an underlying change in one of their dependencies. The project manager tried to contact that development team. And, there was some discussion. But, the issue was never resolved for Core. You'll have to load the full comment thread here to find a more specific reason why the issue was closed. In particular, the last comments from SteveL-MSFT should shed light on your question. If I was trying to automate AppX on Windows, I would try to use DISM or PowerShell v5 or some mobile device management software like Intune. I'm sure a sales rep or a "Microsoft-certified solution provider" would have more up-to-date information based on your needs. Regards, |
I know this thread is long, but, from what I can tell, this comment is still a (technically more detailed) summary of the state of affairs. |
|
Steps to reproduce
Use Powershell 7.1 preview 4 or 5
Import-Module Appx
Expected behavior
Actual behavior
Environment data
The module can be imported properly in Powershell 7.0.2 or, in Preview 4/5 using
-UseWindowsPowerShell
.I was able to load the module till 7.1 Preview 3
Is this an expected breaking change? Asking in case I need to update my scripts to use
-UseWindowsPowerShell
The text was updated successfully, but these errors were encountered: