WebFaction
Community site: login faq
2
2

I'd like to install and run .NET Core on my WebFaction account. What are the steps I need to take?

asked 29 Sep '16, 19:01

seanf
12.2k42136
accept rate: 37%


You can install and run a .NET Core application with the following steps (tested on CentOS7, Web500+):

1. Install libunwind in your home directory:

mkdir  ~/src ~/tmp ~/dotnet
export TMPDIR=~/tmp
cd ~/src
git clone git://git.sv.gnu.org/libunwind.git
./autogen.sh --prefix=$HOME
./configure --prefix=$HOME
make
make install

2. Download and install .NET Core in your home directory:

cd ~
export LD_LIBRARY_PATH=$HOME/lib
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=827529
tar zxf dotnet.tar.gz -C ~/dotnet
ln -s ~/dotnet/dotnet ~/bin/

3. Create a "Custom app (listening on port)" application in our control panel, make a note of the app's name and port number (myapp and 12345 in the examples to follow), and attach the app to a website.

4. Initialize your dotnet application:

cd ~/webapps/myapp
dotnet new

5. Edit the app's project.json so it looks like this:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        },
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
      },
      "imports": "dnxcore50"
    }
  }
}

6. Run the following from your app directory to pull in dependencies:

dotnet restore

7. Create Startup.cs in your app directory like this:

using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;

namespace aspnetcoreapp
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.Run(context =>
            {
                return context.Response.WriteAsync("Hello from ASP.NET Core!");
            });
        }
    }
}

8. Edit Program.cs to set your app port, like this:

using System;
using Microsoft.AspNetCore.Hosting;

namespace aspnetcoreapp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseStartup<Startup>()
                .UseUrls("http://localhost:12345")
                .Build();

            host.Run();
        }
    }
}

9. Finally, run it:

dotnet run

At that point, you'll have a basic "Hello World" app running on the site you set up in step 3.

Hope that helps!

permanent link

answered 29 Sep '16, 19:01

seanf
12.2k42136
accept rate: 37%

edited 04 Oct '16, 21:44

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×2
×2

question asked: 29 Sep '16, 19:01

question was seen: 2,995 times

last updated: 04 Oct '16, 21:44

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM