【发布时间】:2017-01-01 16:29:29
【问题描述】:
有没有办法从 .net-core 运行 PowerShell 脚本?
我正在尝试在新的 .net 核心“网站\api”中运行 PowerShell 脚本。 据我所知,为了在 .net 上运行 PowerShell,我们需要添加
System.Management.Automation 命名空间。
这对于 .net core 是不可能的(或者我还没有找到合适的方法来添加它)。 有几个 NuGet 包也旨在将此 DLL 添加到项目中,但它们也不与 .net 核心兼容。 有没有办法在.net core 上做到这一点? 以下是我尝试过的一些链接,但它们都不是特定于 .net 核心的:
http://www.powershellmagazine.com/2014/03/18/writing-a-powershell-module-in-c-part-1-the-basics/
Referencing system.management.automation.dll in Visual Studio
https://www.nuget.org/packages/System.Management.Automation/
【问题讨论】:
-
hun,tek第一个链接是2014
-
第一个链接用于显示通过代码运行 shell 所需的代码(和命名空间)......
-
我也不是 ;) ... 但是,我认为这不是 .NET 团队现在为 .NET Core 策划的命名空间。去 Github Repo 向 Powershell 团队询问。他们应该是策划这种集成的人。在此处提出问题,并提供有关您想要做什么的更具体细节:github.com/PowerShell/PowerShell
-
The powershell-core MyGet feed 包含支持 .Net Core 的
System.Management.Automation的 alpha 版本。这对你有用吗? -
@Thomas - 你也是 Thomas - 非常感谢 - 你们给了我很好的领导
标签: c# .net powershell asp.net-core .net-core