## mcs定位
[mono 5.0.0 releases](http://www.mono-project.com/docs/about-mono/releases/5.0.0/)
> 根据上面的releases,如果想要在mac端生成mdb,必须要用mcs来build,我们先找到自己的mcs在哪
“`shell
$ which mcs
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mcs
“`
## Hotfix.csproj
> 这里的CscToolExe就是上面的mcs路径,这样在Mac环境下Build的时候会自动使用mcs来build
“`xml
“`
> 大家之前最后的mdb都是注释掉的,这里记得要打开
“`xml
“`
## 创建shell文件
> 这里要完成在Unity中点一下编译,所有的东西自动生成
**不要用IDE 来build,会报错**
“`shell
$ vi build.sh
#!/bin/bash
xbuild Unity.Hotfix.csproj
echo done
“`
记得加执行权限
“`shell
$ chmod +x build.sh
“`
现在我们来验证一下,把这里文件全部删除
“`shell
$ cd dll生成的文件夹
$ rm -rf *
$ ls
“`
“`shell
$ cd 刚刚的build.sh文件夹
$ ./build.sh
$ cd dll生成的文件夹
$ ls -l
“`
mdb文件就已经出现在这个文件夹里面了

我们再去Assets/Res/Code里面检查一下,如果不放心,可以把这个文件夹清空,然后再build一遍
“`shell
$ ls -l
“`
mdb 文件也自动过来了

## Unity工具编写
> 新版本的ET ShellHelper已经添加进去了,如果不方便更新可以自行查阅[ET 框架Mac 端工具支持](http://www.liuocean.com/index.php/2018/07/25/et-kuang-jiamac-duan-gong-ju-zhi-chi/)
BuildHelper.cs文件增加以下代码,你在Unity中点一下「编译Hotfix」就全部搞定了
“`csharp
[MenuItem(“Tools/编译Hotfix”)]
public static void BuildHotfix()
{
#if UNITY_EDITOR_OSX
string path = System.Environment.CurrentDirectory + “/Hotfix/”;
(“cd ” + path + ” && bash build.sh”).Bash(path, true);
#else
System.Diagnostics.Process process = new System.Diagnostics.Process();
string unityDir = System.Environment.GetEnvironmentVariable(“Unity”);
if (string.IsNullOrEmpty(unityDir))
{
Log.Error(“没有设置Unity环境变量!”);
return;
}
process.StartInfo.FileName = $@”{unityDir}\Editor\Data\MonoBleedingEdge\bin\mono.exe”;
process.StartInfo.Arguments = $@”{unityDir}\Editor\Data\MonoBleedingEdge\lib\mono\xbuild\14.0\bin\xbuild.exe .\Hotfix\Unity.Hotfix.csproj”;
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = @”.\”;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
string info = process.StandardOutput.ReadToEnd();
process.Close();
#endif
}
“`