7
In part 1, we set up TFS. In part 2, we configured our Linux build agent. Now in part 3, we'll be setting up DNX (the .NET Execution Environment) for Linux. Since DNX/ ASP .NET 5 is still in development, we'll be going against the latest dev branch for extra fun. You can find more details on the ASPNET GitHub page. First up, we need to install Mono, the open-source CLR and BCL implementation. Run the following commands to get that process started. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list sudo apt-get update sudo apt-get install mono-complete As always, answer any prompts that come up with "yes", and wait patiently. Installing Mono takes a while! When it's done, run mono --version If everything is okay, you'll see this: Mono JIT compiler version 4.0.3 (Stable 4.0.3.20/d6946b4 Tue Aug 4 09:43:57 UTC 2015) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notifications: epoll Architecture: amd64 Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen Now we can install DNVM/DNX. sudo apt-get install unzip curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh Run those commands, answer "yes" to any prompts, and when they're complete, run the dnvm command to test that everything is installed: ___ _ ___ ____ ___ / _ \/ |/ / | / / |/ / / // / /| |/ / /|_/ /

Building ASP .NET 5 Applications on Linux with TFS 2015, Part 3: Installing DNX

Embed Size (px)

Citation preview

Page 1: Building ASP .NET 5 Applications on Linux with TFS 2015, Part 3: Installing DNX

In part 1, we set up TFS.In part 2, we configured our Linux build agent.Now in part 3, we'll be setting up DNX (the .NET Execution Environment) for Linux. Since DNX/ ASP .NET 5 is still in development, we'll be going against the latest dev branch for extra fun. You can find more details on the ASPNET GitHub page.First up, we need to install Mono, the open-source CLR and BCL implementation.Run the following commands to get that process started.sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EFecho "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.listsudo apt-get updatesudo apt-get install mono-completeAs always, answer any prompts that come up with "yes", and wait patiently. Installing Mono takes a while!When it's done, run mono --versionIf everything is okay, you'll see this:Mono JIT compiler version 4.0.3 (Stable 4.0.3.20/d6946b4 Tue Aug 4 09:43:57 UTC 2015)Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.comTLS: __threadSIGSEGV: altstackNotifications: epollArchitecture: amd64Disabled: noneMisc: softdebugLLVM: supported, not enabled.GC: sgenNow we can install DNVM/DNX.sudo apt-get install unzipcurl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh

Run those commands, answer "yes" to any prompts, and when they're complete, run thednvm command to test that everything is installed:___ _ ___ ____ ___/ _ \/ |/ / | / / |/ // // / /| |/ / /|_/ //____/_/|_/ |___/_/ /_/.NET Version Manager - Version 1.0.0-beta7-10410By Microsoft Open Technologies, Inc.DNVM can be used to download versions of the .NET Execution Environment and mana ge which version you are using.You can control the URL of the stable and unstable channel by setting the DNX_FE ED and DNX_UNSTABLE_FEED variables.Current feed settings:Default Stable: https://www.nuget.org/api/v2Default Unstable: https://www.myget.org/F/aspnetvnext/api/v2Current Stable Override:Current Unstable Override:

Page 2: Building ASP .NET 5 Applications on Linux with TFS 2015, Part 3: Installing DNX

Use dnvm [help|-h|-help|--help] to display help text.Then, we need to make sure we have the most recent DNX, so run dnvm upgrade -uYou'll see text along these lines:Determining latest versionLatest version is 1.0.0-beta7-12340Downloading dnx-mono.1.0.0-beta7-12340 from https://www.myget.org/F/aspnetvnext/api/v2Download: https://www.myget.org/F/aspnetvnext/api/v2/package/dnx-mono/1.0.0-beta7-12340######################################################################## 100.0%Installing to /home/ictfs-admin/.dnx/runtimes/dnx-mono.1.0.0-beta7-12340Adding /home/ictfs-admin/.dnx/runtimes/dnx-mono.1.0.0-beta7-12340/bin to process PATHSetting alias 'default' to 'dnx-mono.1.0.0-beta7-12340'Make a note of that path -- you'll need it later.We also need to add a package source to our NuGet.Config, so modify ~/.config/NuGet/NuGet.Config:sudo nano ~/.config/NuGet/NuGet.ConfigCopy and paste this config into that file and save it. It's okay if the file is empty right now!Now, a few more prerequisites. We have to install Libuv in order to test that DNX is working properly, so run these commands:sudo apt-get install automake libtool curl

Answer "yes" to any prompts.Then run:curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/srccd /usr/local/src/libuv-1.4.2sudo sh autogen.shsudo ./configuresudo makesudo make installsudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/sudo ldconfigFinally, we need Git so that we can clone the ASPNET repo with the sample projects in it.sudo apt-get install gitAnswer "yes" to any prompts.Now we can clone the repo with the sample code in it:cd ~git clone https://github.com/aspnet/Home.gitNavigate into the cloned repo:cd Home/samples/latest/HelloWebRun the DNU utility to restore the missing NuGet packages. There are some performance issues with this, so first runexport MONO_THREADS_PER_CPU=2000thendnu restoreIf you get an error at this step, runsudo service unscd stop, then rerundnu restoreYou may also get some errors about missing packages. This is a development repo, so stuff is in a state of flux. When I was writing this blog, I had to open up project.json and add two dependencies:

Page 3: Building ASP .NET 5 Applications on Linux with TFS 2015, Part 3: Installing DNX

"Microsoft.CodeAnalysis.CSharp": "1.0.0-*","System.Reflection.Metadata": "1.0.0-*"and rerun the package restore.Once the restore is done successfully, we can test that everything is installed and working properly by runningdnx kestrelYou should seeApplication started. Press Ctrl+C to shut down.You should be able to open up a browser and navigate to http://yourbuildserver:5004/ and see the ASP .NET welcome page.Okay, you're done! Your environment is correctly configured to build ASP .NET 5 applications using DNX!In our last blog post, we'll create a new TFS build definition that will build and package up this application for deployment!- See more at: http://www.incyclesoftware.com/2015/08/building-asp-net-5-applications-on-linux-with-tfs-2015-part-3-installing-dnx/#sthash.6DTnLGaa.dpuf In part 1, we set up TFS.In part 2, we configured our Linux build agent.Now in part 3, we'll be setting up DNX (the .NET Execution Environment) for Linux. Since DNX/ ASP .NET 5 is still in development, we'll be going against the latest dev branch for extra fun. You can find more details on the ASPNET GitHub page.First up, we need to install Mono, the open-source CLR and BCL implementation.Run the following commands to get that process started.sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EFecho "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.listsudo apt-get updatesudo apt-get install mono-completeAs always, answer any prompts that come up with "yes", and wait patiently. Installing Mono takes a while!When it's done, run mono --versionIf everything is okay, you'll see this:Mono JIT compiler version 4.0.3 (Stable 4.0.3.20/d6946b4 Tue Aug 4 09:43:57 UTC 2015)Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.comTLS: __threadSIGSEGV: altstackNotifications: epollArchitecture: amd64Disabled: noneMisc: softdebugLLVM: supported, not enabled.GC: sgenNow we can install DNVM/DNX.sudo apt-get install unzipcurl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh

Run those commands, answer "yes" to any prompts, and when they're complete, run thednvm command to test that everything is installed:

Page 4: Building ASP .NET 5 Applications on Linux with TFS 2015, Part 3: Installing DNX

___ _ ___ ____ ___/ _ \/ |/ / | / / |/ // // / /| |/ / /|_/ //____/_/|_/ |___/_/ /_/.NET Version Manager - Version 1.0.0-beta7-10410By Microsoft Open Technologies, Inc.DNVM can be used to download versions of the .NET Execution Environment and mana ge which version you are using.You can control the URL of the stable and unstable channel by setting the DNX_FE ED and DNX_UNSTABLE_FEED variables.Current feed settings:Default Stable: https://www.nuget.org/api/v2Default Unstable: https://www.myget.org/F/aspnetvnext/api/v2Current Stable Override:Current Unstable Override:Use dnvm [help|-h|-help|--help] to display help text.Then, we need to make sure we have the most recent DNX, so run dnvm upgrade -uYou'll see text along these lines:Determining latest versionLatest version is 1.0.0-beta7-12340Downloading dnx-mono.1.0.0-beta7-12340 from https://www.myget.org/F/aspnetvnext/api/v2Download: https://www.myget.org/F/aspnetvnext/api/v2/package/dnx-mono/1.0.0-beta7-12340######################################################################## 100.0%Installing to /home/ictfs-admin/.dnx/runtimes/dnx-mono.1.0.0-beta7-12340Adding /home/ictfs-admin/.dnx/runtimes/dnx-mono.1.0.0-beta7-12340/bin to process PATHSetting alias 'default' to 'dnx-mono.1.0.0-beta7-12340'Make a note of that path -- you'll need it later.We also need to add a package source to our NuGet.Config, so modify ~/.config/NuGet/NuGet.Config:sudo nano ~/.config/NuGet/NuGet.ConfigCopy and paste this config into that file and save it. It's okay if the file is empty right now!Now, a few more prerequisites. We have to install Libuv in order to test that DNX is working properly, so run these commands:sudo apt-get install automake libtool curl

Answer "yes" to any prompts.Then run:curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/srccd /usr/local/src/libuv-1.4.2sudo sh autogen.shsudo ./configuresudo makesudo make installsudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/sudo ldconfigFinally, we need Git so that we can clone the ASPNET repo with the sample projects in it.sudo apt-get install gitAnswer "yes" to any prompts.Now we can clone the repo with the sample code in it:cd ~

Page 5: Building ASP .NET 5 Applications on Linux with TFS 2015, Part 3: Installing DNX

git clone https://github.com/aspnet/Home.gitNavigate into the cloned repo:cd Home/samples/latest/HelloWebRun the DNU utility to restore the missing NuGet packages. There are some performance issues with this, so first runexport MONO_THREADS_PER_CPU=2000thendnu restoreIf you get an error at this step, runsudo service unscd stop, then rerundnu restoreYou may also get some errors about missing packages. This is a development repo, so stuff is in a state of flux. When I was writing this blog, I had to open up project.json and add two dependencies:"Microsoft.CodeAnalysis.CSharp": "1.0.0-*","System.Reflection.Metadata": "1.0.0-*"and rerun the package restore.Once the restore is done successfully, we can test that everything is installed and working properly by runningdnx kestrelYou should seeApplication started. Press Ctrl+C to shut down.You should be able to open up a browser and navigate to http://yourbuildserver:5004/ and see the ASP .NET welcome page.Okay, you're done! Your environment is correctly configured to build ASP .NET 5 applications using DNX!In our last blog post, we'll create a new TFS build definition that will build and package up this application for deployment!