Over a million developers have joined DZone.

Shell Script to setup .NET on Linux

· Java Zone

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

If you are scared by the tedious process of setting up Mono, KVM and KRE on Linux or are not aware of how to get started with it, here is your lifesaver – a single Shell script that can do magic for you.  You don’t need to know anything special to run this.  All you need is an access to Linux VM.  Once you have logged in to a VM using any client (like PuTTy) and run the script. 




if [ -z $PREFIX ]; then

if [ -z $VERSION ]; then

sudo apt-get install make
sudo apt-get install git autoconf libtool automake build-essential mono-devel gettext zip unzip
sudo apt-get install bash zsh curl

sudo mkdir $PREFIX
sudo chown -R `whoami` $PREFIX

wget http://download.mono-project.com/sources/mono/mono-$VERSION.tar.bz2
tar -xjvf mono-$VERSION.tar.bz2
cd mono-$VERSION
./autogen.sh --prefix=$PREFIX
make install

sudo certmgr -ssl -m https://go.microsoft.com
sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
sudo certmgr -ssl -m https://nuget.org
sudo certmgr -ssl -m https://www.myget.org/F/aspnetvnext/

mozroots --import –sync

wget http://dist.libuv.org/dist/v1.0.0-rc1/libuv-v1.0.0-rc1.tar.gz 
tar -xvf libuv-v1.0.0-rc1.tar.gz
cd libuv-v1.0.0-rc1/
./gyp_uv.py -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.0.0-rc1
sudo ln -s libuv.so.1.0.0-rc1 /usr/lib/libuv.so.1

curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh & source ~/.kre/kvm/kvm.sh

source ~/.kre/kvm/kvm.sh

kvm upgrade

mono --version

All you have to do is save this file as say SetupDotNetOnLinux.sh and on your Linux VM, execute this script.  It may prompt you for Y/N at times and keep answering Y everytime

Those who need help in executing this script, a short way I use is

chmod u+x SetupDotNetOnLinux.sh
ls -l SetupDotNetOnLinux.sh
sh SetupDotNetOnLinux.sh

There are several other ways of executing scripts on Linux.  A simple article that can be helpful is Creating and running a script

Update – 6 Dec:  Added script for Libuv.  Thanks to David Fowler for pointing it.
Also script is available on GitHub.  Any suggestions to improve it, please fork the script

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.


Published at DZone with permission of Punit Ganshani, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}