Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Shell Script to setup .NET on Linux

DZone's Guide to

Shell Script to setup .NET on Linux

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

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. 

#!/bin/bash

clear

PREFIX=$1
VERSION=$2

if [ -z $PREFIX ]; then
  PREFIX="/usr/local/"
fi

if [ -z $VERSION ]; then
  VERSION="3.10.0"
fi


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

PATH=$PREFIX/bin:$PATH
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
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




Are you using Bitbucket to accomplish your company's mission? Share your company’s mission with #Forthecode for a chance to be featured on our homepage, our social media channels, or win a free t-shirt!

Topics:

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

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}