ASP.NET core 搭建于 Deepin 2015.4 记录
2019独角兽企业重金招聘Python工程师标准>>>
2017-05-13更新,可用,自己傻逼才会在Linux下用微软的烂玩意!!!
最新参考网页:
- https://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-install-script
- https://www.microsoft.com/net/download/linux
- https://github.com/dotnet/core-setup/issues/545
参考网页:
- http://www.cnblogs.com/kulong995/p/5467570.html
- https://github.com/dotnet/cli/issues/2018
- https://github.com/dotnet/cli
- https://code.visualstudio.com/docs/runtimes/dotnet
- https://www.microsoft.com/net/core#linuxdebian
- http://download.csdn.net/detail/u013003382/9498661
- http://www.10tiao.com/html/391/201510/400047239/1.html
抱歉,微软的东西比较恶心,网址竟然变了,一部分失效了。更改。如有异常,请自行解决。
一、生活如此不堪
因为开发速度太慢,导致老大看不过去了,直接购买了别人的网站,之前使用PHP开发的,别人的源码是ASP.NET的,所幸对方提供源码,要给对方升级?
二、搭建ASP.NET的工作环境
一直使用Linux Deepin操作系统,已经两三年了,没有在电脑上存在Windows系统了,突然要装个盗版windows系统,实在不情愿,折腾系统太费劲了。遂用 VS Code和ASP.NET Core一起,在Deepin下,可否更好一点呢?就这样搭建吧。
三、搭建过程
1、安装 .NET Core SDK
到这个网页,点击下载这个文件,假设下载到 Desktop 桌面。
由于默认不支持 deepin格式,需要修改一下这个脚本。
$ gedit ~/Desktop/dotnet-install.sh
搜素 debian
, debian.8
前,照瓢画葫芦,加入 “deepin.15.4"的内容。
"deepin.15.4")echo "debian"return 0;;"debian.8")echo "debian"return 0;;```
实现deepin 15.4 也可以直接安装。接着输入如下命令。```bash
$ sudo apt-get install curl libunwind8 gettext libicu52
$ sudo su
# mkdir -p /opt/dotnet
# cd /home/<user>/Desktop
# chmod u+x ./dotnet-install.sh
# ./dotnet-install.sh --version 1.0.4 --install-dir /opt/dotnet/
解释
- 最开始使用 sudo 直接执行这些命令,发现 dotnet-install.sh 会报错。无解,遂切换至 root 用户下安装。
- 最后一句的意思:选择 1.0.4 版本,安装目录为 /opt/dotnet/ 。这样选择的原因,是查到了这里 https://github.com/dotnet/core-setup/blob/master/README.md 找了一个老版本稳定点的下载。
- 经过一个漫长的下载过程,可能会成功,也也可能失败。感觉微软这方面做的比较烦,无可奈何。
接下来就是建立链接了
$ sudo ln -s /opt/dotnet/dotnet /usr/local/bin
2、查看版本
dotnet --version
一般会看到版本号,跟上方的 1.0.4
一致。
3、简单例子
cdmkdir wwwcd wwwmkdir testcd testdotnet new
新建一个可能会弹出如下问题。
Template Instantiation Commands for .NET Core CLI.Usage: dotnet new [arguments] [options]Arguments:template The template to instantiate.Options:-l|--list List templates containing the specified name.-lang|--language Specifies the language of the template to create-n|--name The name for the output being created. If no name is specified, the name of the current directory is used.-o|--output Location to place the generated output.-h|--help Displays help for this command.-all|--show-all Shows all templatesSegmentation fault
网上搜了很久,说了很多废话,貌似用之前的解决方案就可以了。
$ sudo dpkg -i /path/to/libcurl3_7.38.0-4+deb8u3_amd64.deb
其中,libcurl3_7.38.0-4+deb8u3_amd64.deb
是在 debian 官网找到下载的。 下面继续测试。
$ sudo apt-get purge curl
$ sudo apt-mark hold libcurl3
$ cd ~/www/test
$ dotnet new
可能会弹出如下的界面
Templates Short Name Language Tags
----------------------------------------------------------------------
Console Application console [C#], F# Common/Console
Class library classlib [C#], F# Common/Library
Unit Test Project mstest [C#], F# Test/MSTest
xUnit Test Project xunit [C#], F# Test/xUnit
ASP.NET Core Empty web [C#] Web/Empty
ASP.NET Core Web App mvc [C#], F# Web/MVC
ASP.NET Core Web API webapi [C#] Web/WebAPI
Solution File sln Solution Examples:dotnet new mvc --auth None --framework netcoreapp1.1dotnet new mvc --framework netcoreapp1.1dotnet new --help
输入如下命令,
$ dotnet new mvc --auth None --framework netcoreapp1.1
新建并初始化,
$ dotnet restore$ dotnet run
4、安装 Yeoman, Bower, Grunt, Gulp, ASP.NET core 等的生成器
本小点内容主要参考该书.
sudo npm install -g yo bower grunt-cli gulp
sudo npm install -g generator-aspnet
解释
- 假设你已经成功安装了 npm,如需请百度怎么安装。
5、另外一个简单例子
cd ~/wwwyo aspnet
解释
- 按照输出提示,新建一个 WebLM 的网站,显示内容如下。
yo aspnet
? ==========================================================================
We're constantly looking for ways to make yo better!
May we anonymously report usage statistics to improve the tool over time?
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== Yes_-----_ ╭──────────────────────────╮| | │ Welcome to the │|--(o)--| │ marvellous ASP.NET Core │`---------´ │ generator! │( _´U`_ ) ╰──────────────────────────╯/___A___\ /| ~ | __'.___.'__ ´ ` |° ´ Y ` ? What type of application do you want to create? Web Application
? Which UI framework would you like to use? Bootstrap (3.3.6)
? What's the name of your ASP.NET application? WebLW
解释
- 接下来就是一大堆安装提示信息了,并有如下内容
Your project is now created, you can use the following commands to get goingcd "WebLW"dotnet restoredotnet build (optional, build will also happen when it's run)dotnet ef database update (to create the SQLite database for the project)dotnet run
解释
- 如果提示
bower ECMDERR
之类的信息,可能需要自行安装一些插件 比如
cd ~/www/WebLWbower install
如果没有报错,继续使用上面提示的内容
cd ~/www/WebLWdotnet restoredotnet builddotnet ef database updatedotnet run
根据提示进入 http://localhost:5000/ 应该可以看到如下的界面了。
6、安装 vscode 及其插件
这个比较傻瓜了,直接使用命令即可
sudo apt-get install vscode -y
其他插件安装可以自行百度。 我现在安装的插件有
- donjayamanne.githistory-0.0.10
- ms-vscode.csharp-1.4.0
- felixfbecker.php-debug-1.9.4
- ms-vscode.omnisharp-0.3.3
- Kasik96.format-indent-1.3.0
四、打补丁
现在直接使用命令 code
打开 vscode,发现会弹出
[ERROR] Could not locate an OmniSharp server that supports your Linux distribution.OmniSharp provides a richer C# editing experience, with features like IntelliSense and Find All References.
It is recommend that you download the version of OmniSharp that runs on Mono using the following steps:1. If it's not already installed, download and install Mono (https://www.mono-project.com)2. Download and untar the latest OmniSharp Mono release from https://github.com/OmniSharp/omnisharp-roslyn/releases/3. In Visual Studio Code, select Preferences->User Settings to open settings.json.4. In settings.json, add a new setting: "omnisharp.path": "/path/to/omnisharp/OmniSharp.exe"5. In settings.json, add a new setting: "omnisharp.useMono": true6. Restart Visual Studio Code.
1、关于 Mono 的安装
sudo apt-get install mono-complete
算是安装成功啦。
2、下载 OmniSharp Mono Release
到:https://github.com/OmniSharp/omnisharp-roslyn/releases/ 下载最新的,当前 v1.9-beta14,解压缩后,放在 ~/.vscode文件夹下
cd ~/.vscodemkdir omnisharpcd omnisharpcp /path/to/omnisharp-mono.tar.gz ./tar zxvf omnisharp-mono.tar.gzls
解释 会在这个文件夹下发现 ~/.vscode/omnisharp/OmniSharp.exe 文件,对就是这个带 exe 的文件,按照上面的说法,Visual Studio Code, 选择 Preferences->User Settings 打开 settings.json. 在 settings.json, 加上 "omnisharp.path": "/path/to/omnisharp/OmniSharp.exe" 和"omnisharp.useMono": true
// Place your settings in this file to overwrite the default settings
{"omnisharp.path": "/home/litianci/.vscode/omnisharp/OmniSharp.exe","omnisharp.useMono": true
}
解释
- 里面的地址需要根据实际情况修改。
- 重启 vscode.
2、安装 dnvm, dnv,dnx 等
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
安装好了 dnvm, 需要自己首先安装 curl
dnvm upgrade -r mono
dnvm upgrade -r coreclr # 先安装吧,不为过。
sudo apt-get install mono-complete # 安装全套,我也不知道需要不需要更多内容
sudo apt-get install libuv1 # 安装 libuv1
3、使用 vscode 打开上述例子。
这里不再废话,有问题,欢迎下面留言。
五、VSCode 一个复杂的 quizz 例子
代码复制于 http://download.csdn.net/detail/u013003382/9498661 某章节,下面试着在 deepin 下熟悉 C# 和 ASP.NET core 的一般编写过程。(待续)
转载于:https://my.oschina.net/bubifengyun/blog/738634
ASP.NET core 搭建于 Deepin 2015.4 记录相关推荐
- ASP.NET Core ---日志
一.日志记录: 1.日志的作用: 程序中记录日志一般有两个目的,故障定位和显示程序运行状态.好的日志记录方式可以提供足够多定位问题的依据. 2.日志的等级: 有良好工作习惯的人,工作的时候会将领导交 ...
- Visual Studio 2015/2017 与ASP.NET CORE 联合创建具有SPA模式的Angular2模板
虽然注册博客园很久,但是一直没有什么可写的,真心感觉好尴尬了,这次终于找到了一点可以写,有点小兴奋和小害羞呢. 进入主题,前端SPA模式越来越受到欢迎,Core 也开始被很多企业提上日程,但是因为这个 ...
- asp.net core 系列 20 EF基于数据模型创建数据库
一.概述 本章使用 Entity Framework Core 构建执行基本数据访问的 ASP.NET Core MVC 应用程序.使用迁移(migrations)基于数据模型创建数据库,是一种cod ...
- ASP .NET Core Web Razor Pages系列教程三:自动生成Razor Pages (CRUD)
系列文章目录:系列教程:使用ASP.NET Core创建Razor Pages Web应用程序 - zhangpeterx的博客 系列教程代码的GitHub地址:ASP .Net Core Razor ...
- ASP.NET Core 中文文档 第二章 指南(4.4)添加 Model
原文:Adding a model 作者:Rick Anderson 翻译:娄宇(Lyrics) 校对:许登洋(Seay).孟帅洋(书缘).姚阿勇(Mr.Yao).夏申斌 在这一节里,你将添加一些类来 ...
- IIS部署ASP.Net Core 502.5错误和解决
在Win7的机器上部署ASP.Net Core程序,老是提示502.5错误. 已经安装了 Microsoft Visual C++ 2015 Redistributable .NET Core Win ...
- ASP.NET CORE 1.0 MVC API 文档用 SWASHBUCKLE SWAGGER实现
from:https://damienbod.com/2015/12/13/asp-net-5-mvc-6-api-documentation-using-swagger/ 代码生成工具: https ...
- asp开发工具_VSCode搭建完美的asp.net core开发环境,看完这篇就够了
引言 由于.net core的全面跨平台,我也在之前的一篇文章中介绍了如何在深度Deepin操作系统上安装并搭建.net core的开发环境,当时介绍的是安装.net core和使用Rider.net ...
- 一起学ASP.NET Core 2.0学习笔记(一): CentOS下 .net core2 sdk nginx、supervisor、mysql环境搭建...
作为.neter,看到.net core 2.0的正式发布,心里是有点小激动的,迫不及待的体验了一把,发现速度确实是快了很多,其中也遇到一些小问题,所以整理了一些学习笔记: 阅读目录 环境说明 安装C ...
最新文章
- 数组的相乘java_Java程序的数组元素相乘
- 好书推荐:《零基础快速入行入职软件测试工程师》学测试一本就
- PTA 基础程序编程集 7-2 然后是几点 C语言
- Cocoa的MVC架构分析
- verilog中数组的定义_开源仿真工具Icarus Verilog中的verilog parser
- 《数字城堡》大片制作
- Python 基础:分分钟入门
- matlab练习程序(LMS)
- python中‘/’和‘//’区别
- 基于SSM的车辆管理系统
- spoon mysql教程_Kettle-Spoon入门示例
- 【HUSTOJ】1052: 字符图形8-数字三角
- 使用tsx开发vue项目入门
- 【ceph】CEPH 单活MDS主从切换流程|REPLAY
- 2022-5-17-验证外星语词典
- 转行做“程序员”很难?这里有几个建议...
- 微信小程序---页面刷新的几种方法
- appinventor mysql_利用AppInventor实现登录功能(完整版).docx
- 每个 Apache Kafka 开发者都应该知道的5件事
- stm32f103停止模式低功耗设置(最低5.7ua)