我在macOS上使用mono并尝试编译此C#代码:https://gist.github.com/bneg/bf8c05664324e3efeb1fb05902152a20
使用以下命令:
mcs Program.cs
产生以下错误:
Program.cs(4,14): error CS0234: The type or namespace name `Management' does not exist in the namespace `System'. Are you missing an assembly reference?
Program.cs(5,14): error CS0234: The type or namespace name `Management' does not exist in the namespace `System'. Are you missing an assembly reference?
我也尝试了以下命令:
mcs -pkg:dotnet Program.cs
我收到了这个错误:
Program.cs(17,25): error CS0234: The type or namespace name `Automation' does not exist in the namespace `System.Management'. Are you missing an assembly reference?
Program.cs(18,25): error CS0234: The type or namespace name `Automation' does not exist in the namespace `System.Management'. Are you missing an assembly reference?
为了编译它应该做出哪些改变?
答案 0 :(得分:1)
我不确定你是否可以通过mac OS上的mono运行PowerShell。
至少你需要引用这样的东西: https://www.nuget.org/packages/System.Management.Automation
但如果您没有安装PowerShell,则无法保证此功能。因为linux上的powershell(sic!)可以only run on .net core,很可能,你无法得到你想要完成的东西。