I'm trying to run a PS script from my C# project with target framework = .Net Core 2.1
I tried this:
PowerShell ps = PowerShell.Create();
ps.AddScript(File.ReadAllText(Properties.PATHTOSCRIPT)).Invoke();
with the <PackageReference Include="Cake.Powershell" Version="1.0.1" />
but this resulted in an error:
System.InvalidProgramException: 'Common Language Runtime detected an invalid program.'
Any suggestions how to run a PS script in C#?