Skip to content

Microsoft.Management.Infrastructure.CimCmdlets nuget package should be published #8119

@Grongrilla

Description

@Grongrilla

I am currently developing a .NET Core 2.1 Console application that should be able to execute PowerShell Scripts.

My starting point was the example provided in PowerShell-6.1.0\docs\host-powershell\sample-dotnet2.0-powershell.beta.3, but depending on the 6.1 release of PowerShell Core. So when I started implementing more and extending my test powershell script, I ran into an issue concerning Microsoft.Management.Infrastructure:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

I am assuming Microsoft.Management.Infrastructure provides CimCmdlets?

I do have the NuGet Package "Microsoft.Management.Infrastructure" in my Project, but the DLLs are not published...

So I had a look at the PowerShell Release zip:

there is a
Microsoft.Management.Infrastructure,
Microsoft.Management.Infrastructure.Native,
Microsoft.Management.Infrastructure.Unmananged and a Microsoft.Management.Infrastructure.CimCmdlets,
which have different versions than the DLLs provided in the NuGet Package "Microsoft.Management.Infrastructure".
Also, the NuGet Package only contains Microsoft.Management.Infrastructure and Microsoft.Management.Infrastructure.Native.

So, is there something wrong with the Nuget Package? Am I using it wrong? What would I need to do if I want to publish a win-x64 Console App hosting PS scripts that supports CimCmdlets, and a linux-x64 Console App hosting PS scripts that do not support CimCmdlets?

I also realized that Get-Modules -ListAvailable did not work (returned nothing) in my test script because I was missing the psd files, which are available in the "Modules" subdir of the PowerShell Release zip.
Are these available as a nuget package? Are they even meant to be redistributed as part of a PowerShell Core Host ".exe"? Also, when I copy that folder manually to my publish dir, some CmdLets complain about a missing ref dir, which is indeed in the PowerShell zip. Same question, is this something specific to pwsh.exe gets redistributed and if I "need" it, I am doing something wrong?

So I guess my question boilds down to this:

What is the correct way to implement and publish a self-contained .exe that supports (potentially) everything, that pwsh.exe can do, but where I have the possibility to control what is executed, and how (runspace, some additional checks, and so on...). Is these even the "correct" way to use PowerShell Core hosting?

Metadata

Metadata

Labels

Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-DevEx-SDKhosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of modules

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions