从.NET Core运行PowerShell [英] Running PowerShell from .NET Core

查看:507
本文介绍了从.NET Core运行PowerShell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从.net-core运行PowerShell脚本?

Is there a way to run PowerShell scripts from .net-core ?

我正在尝试在新的.net核心网站api中运行PowerShell脚本。
据我所知,为了在.net上运行PowerShell,我们需要添加

I'm trying to run a PowerShell script in a new .net core 'website\api'. From what I can tell in order to run PowerShell on .net we need to add the

System.Management.Automation命名空间。

System.Management.Automation namespace.

这对于.net核心是不可能的(或者我还没有找到适当的添加方式)。
有几个NuGet软件包,它们的目的还在于将该DLL添加到项目中,但它们也不与.net核心兼容。
是否可以在.net核心上执行此操作?
这是我尝试过的一些链接,但都不是特定于.net核心的链接。

This isn't possible for .net core ( or I haven't found the appropriate way to add it). There are a couple of NuGet packages which are also aimed at adding this DLL to project but those aren't compatible with .net core either. Is there a way to do this on .net core ? Here are some links I've tried but none of them are .net core specific:

> http://www.powershellmagazine.com/2014/03/18 / writing-a-powershell-module-in-c-part-1-the-basics /

在Visual Studio中引用system.management.automation.dll

https://www.nuget.org/packages/System.Management。自动化/

推荐答案

官方答案:目前不支持从您自己的应用程序运行PowerShell Core。可能最大的问题是.Net Core缺少 AppDomain.GetAssemblies(),该问题可能已在.Net Core 1.2中修复。

The official answer is that running PowerShell Core from your own application is currently not supported. Probably the biggest issue is that .Net Core is missing AppDomain.GetAssemblies(), which might be fixed in .Net Core 1.2.

这篇关于从.NET Core运行PowerShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆