Powershell Core 是否在 .NET Core 上运行? [英] Does Powershell Core run on .NET Core?

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

问题描述

标题说明了一切.

维基百科:

最初只是一个 Windows 组件,称为 Windows PowerShell,它于 2016 年 8 月 18 日成为开源和跨平台的PowerShell Core 的介绍. [4]前者建立在 .NET 之上框架,而后者在 .NET Core 上.

Initially a Windows component only, known as Windows PowerShell, it was made open-source and cross-platform on 18 August 2016 with the introduction of PowerShell Core.[4] The former is built on .NET Framework while the latter on .NET Core.

强调.

据我回忆,Powershell Core 应该能够有效地调用Mono.对吗?

From what I recall reading, Powershell Core should be able to invoke, effectively, Mono. Is that correct?

另见:

从 .NET Core 运行 PowerShell

在 Mono 中运行 PowerShell 脚本?

PowerShell 脚本是否在 Mono 下运行?

推荐答案

据我回忆,Powershell Core 应该能够有效地调用 Mono.对吗?

From what I recall reading, Powershell Core should be able to invoke, effectively, Mono. Is that correct?

不管你是什么意思,我暂时怀疑.您可以使用 .Net Core 编译为 Mono 编写的重要代码,反之亦然吗?也许,但并非总是如此.您可以使用 .Net Core 加载为 Mono 编写的库,反之亦然吗?使用 .Net Core 2.0,您应该能够做到这一点,距离测试版不到一年(就像 PowerShell Core 的测试版不到一个月一样).所以,再一次,也许,但并非总是如此.你能在 Mono 代码中使用 Add-Type 并期望它运行吗?也许吧,但您将使用 .Net Core 编译它,而不是 Mono.

Whatever you mean by this, I doubt it for the time being. Can you compile non-trivial code written for Mono with .Net Core and vice-versa? Maybe, but not always. Can you load libraries written for Mono with .Net Core and vice-versa? With .Net Core 2.0 you're supposed to be able to do that that's less than a year out of beta (just like PowerShell Core is less than a month out of beta). So, again, maybe, but not always. Can you use Add-Type with Mono code and expect it to run? Maybe, but you'll be compiling it with .Net Core, not Mono.

如果您的意思是从 PowerShell Core,调用一个巧合的是使用 Mono 编写的已编译程序".在那种情况下,是的,你总是可以这样做.这是一个壳.您可以使用它运行外部程序.

If you mean "From PowerShell Core, call a compiled program which coincidentally was written using Mono." In that case, yeah, you can always do that. It's a shell. You can run external programs with it.

Mono 和 .Net Core 是在 Linux 上运行的 .Net CLR 的两种实现,但不能保证它们始终兼容,并且它们不实现相同的命名空间集..Net Core 代码甚至不一定与 .Net Framework 源代码兼容.最好将它们视为同一语言的不同实现,例如 Visual C++ 与 GNU C++,或者 IBM Java 与 Oracle Java.

Mono and .Net Core are two implementations of the .Net CLR that run on Linux, but they're not guaranteed to always be compatible and they don't implement an identical set of namespaces. .Net Core code isn't even necessarily compatible with .Net Framework source code. It's best to think of them as different implementations of the same language, like Visual C++ vs GNU C++, or IBM Java vs Oracle Java.

随着时间的推移,它们将融合为一个支持单个 CLR 标准(.Net 标准),但我们正处于这一旅程的开始..Net Core 1.x 非常简单..Net Core 2.0 充实了很多,但它仍然非常非常早.Mono 现在是 MS 产品,但可能有些组件不能混合使用.Mono 和 .Net Core(以及 .Net Framework 和 Unity)最终应该支持 .Net Standard,这是一种 EMCA 标准,但它们从未打算 100% 相同.我怀疑当我们到达 .Net Core 4 左右时,我们将拥有.Net Core",它实现了 .Net Standard 的所有内容,然后是.Net Windows Framework"作为扩展,其中包含原始 .Net Core 中缺少的东西.Net 框架,也许是.Net Linux 框架"来在 Linux 上做同样的事情.

As time goes on, they will converge into a supporting a single CLR standard (.Net Standard), but we're at the start of that journey. .Net Core 1.x was very bare-bones. .Net Core 2.0 fleshes out a ton, but it's still very, very early. Mono is now a MS product, but there may be components that just don't mix. Mono and .Net Core (and .Net Framework and Unity) are eventually supposed to support .Net Standard which is an EMCA standard, but they're never intended to be 100% identical. I suspect that when we get to .Net Core 4 or so, we'll have ".Net Core" which implements everything from .Net Standard and then a ".Net Windows Framework" as an extension with the missing stuff from the original .Net Framework and maybe a ".Net Linux Framework" to do the same sort of things on Linux.

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

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