其他分享
首页 > 其他分享> > Mono安裝(brew)

Mono安裝(brew)

作者:互联网

Mono安装


关于mono的安装测试记录。

在学习《Web应用安全权威指南》时,由于是macOS所以搭建环境时有点不太一样。根据书本介绍找到fiddler官网,下载之后发现是zip,解压缩没有dmg只有exe
根据官网提示,需要下载mono
不过现在已经有适配macOS的Charles了,界面什么的也对mac较友好。

安装Mono

使用brew安装。

brew install mono

报错:

Error: The following directories are not writable by your user:
/usr/local/sbin
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/sbin
And make sure that your user has write permission.
chmod u+w /usr/local/sbin

输入:

sudo chown -R $(whoami) /usr/local/sbin

重试后,输入

type mono
mono --version

报错

type: mono: not found
mono: command not found

查了一下,如果要在terminal使用mono需要在添加:

export MONO_HOME=/Library/Frameworks/Mono.framework/Home
export PATH=$MONO_HOME/bin:$PATH

(应该要在.bash_profile文件中添加,但是不知道为什么我直接在terminal输入也可以了 ?_? )

再次测试,输入:mono --version。输出:

Mono JIT compiler version 6.0.0.319 (2019-02/52203786470 Thu Aug  1 07:35:17 EDT 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	Interpreter:   yes
	LLVM:          yes(600)
	Suspend:       hybrid
	GC:            sgen (concurrent by default)

输入:type mono。输出:

mono is hashed (/Library/Frameworks/Mono.framework/Home/bin/mono)

确认mono能不能在terminal中正常使用:(官网有很多较详细)
新建hello.cs文件,输入以下代码:

using System;
 
public class HelloWorld
{
    
    public static void Main(string[] args)
    {
        Console.WriteLine ("Hello Mono World");
    }
}

然后terminal进入存放这个文件的文件夹中,编译:

csc hello.cs

编译器会生成hello.exe。
运行:

mono hello.exe 

此时应当输出:

Hello Mono World

完成!

标签:sbin,安裝,Mono,terminal,usr,mono,brew,local
来源: https://blog.csdn.net/sinat_41303638/article/details/98951440