Repository navigation
Microsoft.Management.Infrastructure NuGet package missing dependencies #4562
Description
I'm writing a ASP.NET Core web app that requires accessing CIM information/methods. Microsoft.Management.Infrastructure v4.0.0, available via NuGet, is not .NET Core compatible, so naturally I was curious how CIM works in PowerShell. I found that you are using a powershell-core https://powershell.myget.org/F/powershell-core/api/v3/index.json respository to host Microsoft.Management.Infrastructure v1.0.0-alpha06, so I added that to my project and everything seemed fine until I try to use any code from MMI.
I found a related issue #1204, but that issue was addressed for situations where MMI is used within the context of PowerShell. It looks like the solution was not applied directly to the MMI assembly itself.
I realize that the intention for the PowerShell Core version of MMI is to be used within the context of PowerShell, but it'd be much appreciated if the library was compatible with other use cases like ASP.NET Web Applications.
Steps to reproduce
I've posted a sample project so you can see how I am attempting to use the library.
Expected behavior
calc.exe runs on the remote host (localhost in this case). This is the result on Windows, but not Linux.
Actual behavior
The application crashes with the following error:
Unable to load DLL 'libmi.so': The specified module could not be found.
I found an issue (#2120) that talks about libmi.so being part of OMI, so I installed OMI and borrowed it. This fixed the first issue, but another issue came up with the following error:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Microsoft.Management.Infrastructure.Strings.resources" was correctly embedded or linked into assembly "Microsoft.Management.Infrastructure" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Environment data
The goal is to Dockerize this app, so the test system I am using is Docker's microsoft/aspnetcore Image (Debian Jessie).
uname -a
Linux ace-app 4.9.36-moby #1 SMP Wed Jul 12 15:29:07 UTC 2017 x86_64 GNU/Linux
Activity
iSazonov commentedon Aug 13, 2017
Dongbo Wang (@daxian-dbw) Could you please comment?
SteveL-MSFT commentedon Aug 14, 2017
The history of MMI is a bit complicated. MMI (aka WMIv2) was originally written in managed C++. Managed C++ is no longer supported. There was work started to have a pure C# implementation, but it was only sufficient for PowerShell purposes and not a replacement for the original. Since the industry has moved away from CIM towards JSON, it hasn't been a priority to complete the port.
jaredcatkinson commentedon Aug 14, 2017
Interesting. I was hoping there'd be a more straightforward solution, but I think I can probably just call Invoke-CimMethod from my assembly and get the result I'm looking for. I'd be interested in learning more about the JSON implementation you mentioned. Is it built on WMI/CIM? IMO, one of the most beneficial features of WMI/CIM is its ubiquity. I'd be worried if it was going to be killed off in future OS releases.
SteveL-MSFT commentedon Aug 14, 2017
To clarify, WMI/CIM isn't being deprecated from Windows, however, no new development is happening in that area (it's basically considered complete).
The JSON mention is about Redfish which we support via ODataUtils already.
I think calling the CIM cmdlets via code is a fine solution.
SteveL-MSFT commentedon Aug 30, 2017
Reusing this issue to track completion of port of MMI to pure managed code.
SteveL-MSFT commentedon Jun 20, 2018
No plans to port MMI to C#