在你的andorid设备上运行netcore (Linux Deploy)

最近注意到.net core 的新版本已经开始支持ARM 平台的CPU, 特意去Linux Deploy 中尝试了一下,真的可以运行

Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.9.65-perf+ armv8l)

 * Documentation:  https://help.ubuntu.com/
Ubuntu 16.04 LTS [running via Linux Deploy]
Last login: Thu Oct  4 20:15:39 2018 from 127.0.0.1
root@localhost:~# dotnet

Usage: dotnet [options]
Usage: dotnet [path-to-application]

Options:
  -h|--help         Display help.
  --info            Display .NET Core information.
  --list-sdks       Display the installed SDKs.
  --list-runtimes   Display the installed runtimes.

path-to-application:
  The path to an application .dll file to execute.
root@localhost:~#

  

此处分享下操作步骤 :

  1. root 你的安卓设备
  2. 安装Linux Deploy
  3. 配置Linux Deploy 安装 Ubuntu 
  4. 安装netcore
  5. 在Linux中启用root 账户密码登陆
  6. 推荐的android ssh工具 :juiceSSH

1. root 你的安卓设备

这个根据不同手机厂商有不同的root 方法,我的是OnePlus6 官方给的root工具。

2. 安装Linux Deploy

随便一个应用商店应该都有吧,百度360或者豌豆荚

3.. 配置Linux Deploy 安装 Ubuntu 

 为了提升安装速度 建议将镜像源修改为清华的:https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/

下图中未截到的默认即可,需要注意的是要勾选ssh,和修改默认用户的登陆密码,架构选择 arm64,其它配置如下:

 另外以上的图形子系统非必要,本来打算安装个 vs code ,但是官方没有提供 arm版本~。

4. 安装netcore

    从以下地址下载Linux ARM64的安装包:

  https://www.microsoft.com/net/download/dotnet-core/2.1

在下载界面下方会有一些官方建议的安装步骤,官方命令的$home代表当前用户, 为了避免产生权限问题我的安装环境是直接挂在到根目录的,你也可以放到如: /etc/dotnet 

安装web下载器 wget

apt-get install wget 

注意,wget 后跟的是下载地址,这个地址来自于下载页面弹出的下载文件的地址,或者 在Try again上点击右键复制连接

wget https://download.visualstudio.microsoft.com/download/pr/00038a67-bb86-4c39-88df-7c0998002a9e/97de51fd691c68e18ddd3dcaf3d60181/dotnet-sdk-2.1.403-linux-arm64.tar.gz

然后在Linux 系统中执行以下命令:  

mkdir -p /etc/dotnet && tar zxf dotnet-sdk-2.1.403-linux-arm64.tar.gz -C /etc/dotnet
export DOTNET_ROOT=$PATH:/etc/dotnet 
export PATH=$PATH:/etc/dotnet

 

配置环境变量:

切换到root用户

sudo apt-get install vim
su root
vim /etc/profile

键盘输入i
按方向键向下到底,在最后一行下面插入以下两行
vim /etc/profile

export PATH=$PATH:/etc/dotnet
export DOTNET_ROOT=$PATH:/etc/dotnet
#然后按 ESC键 并输入 :wq
source /etc/profile

运行 dotnet --version 测试

如果报 如下错误: 

FailFast:
Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globaliz ation support.

执行如下命令进行安装icu开发包

sudo apt-get install libicu-dev

5. 在Linux中启用root 账户密码登陆

sudo passwd root 

然后输入密码

6. 推荐的android 版 ssh工具 :

juiceSSH

原文连接:https://www.cnblogs.com/Qbit/p/andorid-netcore.html

转发请注明出处

原文地址:https://www.cnblogs.com/Qbit/p/andorid-netcore.html