Installing .NET Core on Linux

By Zlatko Knezevic

These instructions will lead you through acquiring the .NET Core DNX SDK via the .NET Version Manager (DNVM) and running a “Hello World” demo on Linux.

.NET Core NuGet packages and the .NET Core DNX SDKs are available on the ASP.NET ‘vnext’ myget feed, which you can more easily view on gallery for the feed.

Setting up the environment

These instructions have been written and tested on Ubuntu 14.04 LTS, since that is the main Linux distribution the .NET Core team uses. These instructions may succeed on other distributions as well. We are always accepting new pull requests on our GitHub repo that address running on other Linux distributions. The only requirement is that they do not break the ability to use Ubuntu 14.04 LTS.

Installing the required packages

Install the libunwind8libssl-dev and unzip packages:

sudo apt-get install libunwind8 libssl-dev unzip

Certificates

You need to import trusted root certificates in order to restore NuGet packages. You can do that with the mozroots tool.

mozroots --import --sync

Installing DNVM

You need DNVM as a starting point. DNVM enables you to acquire one or multiple .NET Execution Environments (DNX). DNVM is a shell script and does not require .NET. You can use the below command to install it.

curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh

Installing the .NET Core DNX

You first need to acquire the CoreCLR DNX.

dnvm install latest -r coreclr -u

You can see the currently installed DNX versions with dnvm list.

dnvm list
Active Version              Runtime Arch Location             Alias
------ ------- ------- ---- -------- -----
* 1.0.0-beta5-11649 coreclr x64 ~/.dnx/runtimes

Using a specific runtime

You can choose which of the installed DNXs you want to use with dnvm use, specifying arguments that are similar to the ones used when installing a runtime.

dnvm use -r coreclr -arch x86 1.0.0-beta5-11649
Adding ~/.dnx/runtimes/dnx-coreclr-win-x86.1.0.0-beta5-11649/bin
to process PATH dnvm list Active Version Runtime Arch Location Alias
------ ------- ------- ---- -------- -----
* 1.0.0-beta5-11649 coreclr x64 ~/.dnx/runtimes

See the asterisk in the listing above? It’s purpose is to tell you which runtime is now active. “Active” here means that all of the interaction with your projects and .NET Core will use this runtime.

That’s it! You now have the .NET Core runtime installed on your machine and it is time to take it for a spin.

Write your App

his being an introduction-level document, it seems fitting to start with a “Hello World” app. Here’s a very simple one you can copy and paste into a CS file in a directory.

using System;

public class Program
{
public static void Main (string[] args)
{
Console.WriteLine("Hello, Linux");
Console.WriteLine("Love from CoreCLR.");
}
}

A more ambitious example is available on the corefxlab repo that will print out a pretty picture based on the argument you provide at runtime. If you wish to use this example, simply save the C# file to a directory somewhere on your machine.

The next thing you will need is a project.json file that will outline the dependencies of an app, so you can actually run it. Use the contents below, it will work for both examples above. Save this file in a directory next to the CS file that contains your code.

{
"version": "1.0.0-*",
"dependencies": {
},
"frameworks" : {
"dnx451" : { },
"dnxcore50" : {
"dependencies": {
"System.Console": "4.0.0-beta-*"
}
}
}
}

Run your App

You need to restore packages for your app, based on your project.json, with dnu restore.

dnu restore -s https://www.myget.org/F/aspnetvnext/
dnx run Hello, Linux
Love from CoreCLR. 遇到问题:

No command 'dnx' found

 
解决方案: dnvm upgrade  

Building .NET Core from source

.NET Core is an open source project that is hosted on GitHub. This means that you can, at any given time, clone the repository and build .NET Core from source. This is a more advanced scenario that is usually used when you want to add features to the .NET runtime or the BCL or if you are a contributor to these projects. The detailed instruction on how to build .NET Core windows can be found in theBuild CoreCLR on Linux on GitHub.

http://docs.asp.net/en/latest/getting-started/installing-on-linux.html

asp.net docker

https://github.com/aspnet/aspnet-docker/blob/master/1.0.0-rc1-update1-coreclr/Dockerfile

//设置文件夹权限

you can also use chmod in this way:
who:

u=user (owner) g=group o=other a=all

action:

+=add -=subtract ==set

permission:

r=read w=write x=execute X=special execute (skip files without existing execute permissions) s=setuid/setgid t=sticky

for instance, set execute for files with at least one execute bit set plus read/write for all files in /path/to/set for the owner and his group and set execute for files with at least one execute bit set plus read for others:

Code:
chmod -R ug=rwX,o=rX /path/to/set/

Installing .NET Core on Ubuntu-摘自网络的更多相关文章

  1. Ubuntu的常用快捷键(摘自网络)

    篇一 : Ubuntu的复制粘贴操作及常用快捷键(摘自网络) Ubuntu的复制粘贴操作 1.最为简单,最为常用的应该是鼠标右键操作了,可以选中文件,字符等,右键鼠标,复制,到目的地右键鼠标,粘贴就结 ...

  2. .Net Core 之 Ubuntu 14.04 部署过程

    No.1 准备应用程序 1. 创建.Net Core Web项目 2. 使用VS2015发布 No.2 安装.Net Core for Ubuntu Ubuntu的安装就不介绍了,百度搜索一大堆.本人 ...

  3. Android:控件WebView显示网页 -摘自网络

    WebView可以使得网页轻松的内嵌到app里,还可以直接跟js相互调用. webview有两个方法:setWebChromeClient 和 setWebClient setWebClient:主要 ...

  4. C# 中的内存管理,摘自网络

    C#编程的一个优点是程序员不需要关心具体的内存管理,尤其是垃圾收集器会处理所有的内存清理工作.虽然不必手工管理内存,但如果要编写高质量的代码,还是要理解后台发生的事情,理解C#的内存管理.本文主要介绍 ...

  5. Ubuntu server 网络配置中遇到的问题

    Ubuntu server 网络配置中遇到的问题 图片中ip地址有可能和文字不符,请不要在意太多,知道原理即可 - 1.首先就是要配置ip地址 vim /etc/network/interfaces ...

  6. Ubuntu配置网络遇到的一些问题

    Ubuntu配置网络遇到的一些问题 在配置Ubuntu网络时,曾遇到了一些问题.查找了一些博客,所幸都解决了.记录一下,以便日后查阅. 设置DNS sudo vim /etc/resolv.conf ...

  7. ubuntu解决网络连接的优先级

    ubuntu下无线连接网络,有线连接板卡,解决网络连接的优先级 1. 查看网关  ip route show dev wlp2s0 proto kernel scope link src dev wl ...

  8. Ubuntu的网络共享

    实际场景 公司项目中遇到一个场景:Ubuntu的主机上装了个4G卡(USB模式),需要将这个4G网共享给一个AP,使得所有连接AP的移动设备都可以通过4G上外网 方法很简单: 1. 将4G网口之外的另 ...

  9. 【NS2】Installing ns-2.29 in Ubuntu 12.04

    Installing ns-2.29 in Ubuntu 12.04     Off late, we try to use(install) a old software in a new Oper ...

随机推荐

  1. LINUX下的Mail服务器的搭建

    电子邮件是因特网上最为流行的应用之一.如同邮递员分发投递传统邮件一样,电子邮件也是异步的,也就是说人们是在方便的时候发送和阅读邮件的,无须预先与别人协同.与传统邮件不同的是,电子邮件既迅速,又易于分发 ...

  2. (排序)快速排序QuickSort

    主要内容: 1.算法思想 2.快速排序算法 3.划分算法partition 4.快排过程图解 5.完整代码 1.算法思想 快速排序是C.R.A.Hoare于1962年提出的一种划分交换排序.它采用了一 ...

  3. (回溯法)和为n的所有不增正整数和式分解算法

    题目: 利用递归算法输出正整数和为n的所有不增的正整数和式.例如当n=5时,不增的和式如下: 5=5 5=4+1 5=3+2 5=3+1+1 5=2+2+1 5=2+1+1+1 5=1+1+1+1+1 ...

  4. Codeforces#86D Powerful array(分块暴力)

    Description An array of positive integers a1, a2, ..., an is given. Let us consider its arbitrary su ...

  5. Android提示版本更新的实现

    一.首先,参考了以下文章<Android自动检测版本及自动升级> http://www.linuxidc.com/Linux/2011-10/45718p2.htm: 步骤: .检测当前版 ...

  6. OPENCV 常用函数

    1.cvCloneImage: IplImage* cvCloneImage( const IplImage* image ); 在使用函数之前,不用特地开辟内存,即该函数会自己开一段内存,然后复制好 ...

  7. 从零开始学JavaScript三(变量)

    一.变量 ECMAscript变量是松散型变量,所谓松散型变量,就是变量名称可以保存任何类型的数据,每个变量仅仅是一个用于保存值的占位符. 定义变量时要使用var操作符 如: var message; ...

  8. 算法笔记_175:历届试题 蚂蚁感冒(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 长100厘米的细长直杆子上有n只蚂蚁.它们的头有的朝左,有的朝右. 每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒. 当两只蚂蚁碰面时,它 ...

  9. PHP 循环

    PHP 中的循环语句用于执行相同的代码块指定的次数. 循环 在您编写代码时,您经常需要让相同的代码块运行很多次.您可以在代码中使用循环语句来完成这个任务. 在 PHP 中,我们可以使用下列循环语句: ...

  10. 配置zip版本的Tomcat启动

    1.配置jdk 2.CATALINA_HOME=c:\tomcat CATALINA_BASE=c:\tomcat 3.classpath=%CATALINA_HOME%\common\lib\ser ...