5. Development environment (C#): Linux + Monodevelop

This chapter describes how to use the Monodevelop IDE on a Linux box to develop in C#.

C# 프로젝트는 CentOS 리눅스는 지원하지 않기 때문에 우분투 리눅스를 기준으로 설명합니다.

5.1. Monodevelop 설치하기

Monodevelop IDE 공식 사이트의 설치 가이드에 따르면 Mono 프로젝트에서 공식적으로 지원하는 Mono 저장소를 추가하도록 안내하고 있습니다. 그러나, 아이펀 엔진을 설치하는 과정에서 이미 추가했던 저장소에서 설치가 가능합니다.

만약, Mono 프로젝트 저장소를 추가해야 한다면 Monodevelop IDE 설치 가이드의 저장소 대신 아래 방법에 따라 아이펀 엔진 가이드에서 안내하는 저장소를 설정해 주시기 바랍니다.

Important

우분투 리눅스 배포판 별로 기본적으로 설치되는 Mono 라이브러리 버전이 다릅니다.

아이펀 엔진은 구버전의 Mono 라이브러리도 지원하고 있습니다만, C# 프로젝트의 안정적인 동작을 위해서 아이펀엔진과 Monodevelop 개발도구를 설치하기 전에 반드시 아래 절차를 따라 Mono 라이브러리 저장소를 설정 해 주시기 바랍니다.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

// Ubuntu 16.04 일 경우
echo "deb http://download.mono-project.com/repo/ubuntu stable-xenial/snapshots/6.8 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list

// Ubuntu 18.04 일 경우
echo "deb http://download.mono-project.com/repo/ubuntu stable-bionic/snapshots/6.8 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list

// Ubuntu 20.04 일 경우
echo "deb http://download.mono-project.com/repo/ubuntu stable-focal/snapshots/6.8 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list

Mono 프로젝트 저장소를 추가했다면 apt 명령을 통해서 monodevelop 패키지를 설치하면 됩니다.

sudo apt-get update
sudo apt-get install monodevelop

Important

As of August 2017, iFun Engine does not support the Flatpak MonoDevelop.

5.2. Starting a new project

Enter the following in a command line to start a server project called hello:

$ funapi_initiator hello --csharp

Important

To use Monodevelop IDE, you must create a C# Project. In other words, you must use --csharp as in the example above.

5.3. Opening a project in Monodevelop

  1. Run Monodevelop.

_images/mono-1.png
  1. Click on File in the upper left, then click Open.

_images/mono-2.png
  1. There is a ‘mono’ directory that contains C# files, Go to the directory and open hello.csproj or hello.sln. (If the project name is not “hello”, open {{ProjectName}}.csproj or {{ProjectName}}.sln.)

_images/mono-3.png

Project loading has finished. When the project opens, you can begin coding.

_images/mono-4.png

5.4. Building a Project in Monodevelop

You can build without any special configuration from the Build menu or by pressing F8. You can also right-click the project to use the Build, Rebuild, and Clean features.

_images/mono-5.png

5.4.1. Run a project in Monodevelop on 7 or higher version

You have to select {project-name}-Custom Command to run a project as shown below.

_images/mono-13.png

5.4.2. Migration project with older version

Your project may not build on 7 or higher version. In this case, you can clean the project by removing a build directory({project directory}/mono/bin).

5.5. Debugging a Project in Monodevelop

To debug in Mono, you need to use the Monodevelop IDE’s Mono Soft Mode Debugger.

5.5.1. Configuring using Mono Soft Debugger

Configure settings for the MONODEVELOP_SDB_TEST environment variable to activate Mono Soft Debugger’s features. Enter the following command:

$ echo "export MONODEVELOP_SDB_TEST=1" >> ~/.profile

This is applied when you log out and then in again or when you reboot. You can check the environment variable configuration as follows:

$ echo $MONODEVELOP_SDB_TEST
1

Now, run Monodevelop to check the submenus under Run With. Then Click on the Custom Command Mono Soft Debugger menu.

_images/mono-10.png

Click Listen. Monodevelop IDE is now configured. Monodevelop IDE is now waiting for debugging.

_images/mono-11.png

Now, run the game server and open the debugger. Enter the following:

$ ./hello/mono/bin/Debug/buildcpp/hello-local --mono_debug

Debugging proceeds as follows:

_images/mono-12.png

5.5.2. Using Mono Soft Debugger on 7 or higher version

In 7 version, Mono Soft Debugger feature moved to Custom Configuration menu.

_images/mono-14.png

Click Custom Configuration menu. Then you can see Custom Command Mono Soft Debugger in the following screen

_images/mono-15.png

Important

If you can’t find Custom Command Mono Soft Debugger on the list, you may check $MONODEVELOP_SDB_TEST environment value