I am trying to build a visual studio extension that needs to make some calls to powershell (.NET 8 c# out-of-process VS2022 Preview).
I am adding a nuget package reference to Microsoft.Powershell.SDK and try to instantiate Powershell.
using (PowerShell powerShell = PowerShell.Create(initialSessionState))
If I reference version 7.4.5 of the SDK, during runtime I get the error:
System.IO.FileNotFoundException: ‘Could not load file or assembly ‘System.Management.Automation, Version=7.4.4.0
If I instead reference version 7.4.4 of the powershell SDK, during runtime I get the error:
System.IO.FileNotFoundException: ‘Could not load file or assembly ‘System.Management.Automation, Version=7.4.3.0
And so on…
I can’t add a reference to the missing Automation package since the powershell SDK already references a higher version.
Does anyone know why this happens and how I can remedy the issue?