Thursday, August 1, 2013

Installing Mono on Ubuntu

So I went into the process of installing Mono (from source) on Ubuntu. While the process is pretty straightforward, the problem is no single place to understand the full process. So I am listing the process here for my own sake and it will probably be out of date within 1 week of publishing this post.

Starting point is from a fresh install of Ubuntu Server. I will just list the steps first, then some explanations.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git autoconf libtool gettext pkg-config build-essential
cd ~
git clone git://github.com/mono/mono.git
cd mono
git checkout tags/mono-3.2.0
./autogen.sh --prefix=/usr/local
make get-monolite-latest
make
sudo make install
mozroots --import --ask-remove
sudo vi /etc/environments
add line "EnableNuGetPackageRestore=true"
reboot to load new environments file
modify .nuget\NuGet.targets file in your solution

If you want to host a website with Nginx and FastCGI Mono Server

sudo apt-get install nginx
cd ~
git clone git://github.com/mono/xsp.git
cd xsp
git checkout tags/3.0.11
./autogen.sh --prefix=/usr/local
make
sudo make install

Explanation:

sudo apt-get update
sudo apt-get upgrade

  • You do want all of the O/S updates, right?

sudo apt-get install git autoconf libtool gettext pkg-config build-essential

  • Install packages required to build Mono.
  • Install git to download the source from Github

cd ~
git clone git://github.com/mono/mono.git
cd mono
git checkout tags/mono-3.2.0

  • Download latest source for Mono from Github
  • Rollback source to the latest released version by git tag.

./autogen.sh --prefix=/usr/local
make get-monolite-latest

  • Initial setup to enable build
  • get-monolite-latest will download a "lite" version of the Mono C# compiler. This is required for computers without Mono already installed.

make
sudo make install

  • Build and Install

mozroots --import --ask-remove

  • To add trusted root certificates into your server. You will need to do this to be able to download packages from Nuget's website via https.

sudo vi /etc/environments
add line "EnableNuGetPackageRestore=true"
reboot to load new environments file

  • If you use NuGet Package Restore, this enable it when you build your solution. There is no Visual Studio checkbox you can click.

modify .nuget\NuGet.targets file in your solution

<SolutionDirTrimmed Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir)</SolutionDirTrimmed>
<SolutionDirTrimmed Condition=" '$(OS)' == 'Windows_NT'">$(SolutionDir.Trim('\\'))</SolutionDirTrimmed>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)"  $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDirTrimmed)" </RestoreCommand>

No comments:

Post a Comment