设为首页 收藏本站
查看: 1610|回复: 0

[经验分享] Mac OS 环境下 安装 Asp.Net及使用Yeoman 创建Asp.Net 项目

[复制链接]

尚未签到

发表于 2015-12-29 12:39:16 | 显示全部楼层 |阅读模式
  本文是按照英文原文:Installing ASP.NET 5 On Mac OS安装时遇到的问题的总结Blog。
  原文提示如下:
  Installing ASP.NET 5 On Mac OS X
By Steve Smith
ASP.NET 5 runs on the .NET Execution Environment (DNX), which is available on multiple platforms, including OS X. This article describes how to install DNX, and therefore ASP.NET 5, on OS X, using Homebrew.
In this article:
Install ASP.NET 5 on OS X
Install ASP.NET 5 on OS X
ASP.NET 5 requires DNX, which is installed and managed by the .NET Version Manager (DNVM). The DNVM is easily installed using a tool called Homebrew, which will also install the correct version of Mono for OS X.
Install Homebrew
The first step is to install Homebrew if it's not already installed. This can be done from a Terminal prompt using this script:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  
The installer will inform you of the steps it is taking and pause before proceeding. You can learn more about Homebrew here.
到这一步,可能会出现 brew 已经安装了。
DSC0000.png
可以执行:
brew -v
  
DSC0001.png
Install the .NET Version Manager (DNVM)
Once Homebrew is installed, install the DNVM by running brew tap aspnet/dnx from a Terminal window. If you need to update your version of DNVM, first run brew untap aspnet/dnx to delete the old commands, and then run the brew tap aspnet/dnx command again to get the updated scripts.
DSC0002.png
If you had an older version of our Homebrew "tap" configured, you might get the following error: Could not create link for aspnet/dnx/kvm, as it conflicts with aspnet/k/kvm. In that case, simply run brew uninstall kvm to ensure any old versions of kvm are removed, then brew untap aspnet/k to remove the old tap. After that, the brew tap aspnet/dnx command should succeed.
Next, run the command brew install dnvm to install the .NET Version Manager. This will also automatically install the latest DNX package from the https://www.nuget.org/api/v2 feed.
这一步可能出现没有权限的问题:
DSC0003.png
执行
chown root:wheel /usr/local/bin/brew
  
然后执行
brew link mono
  
DSC0004.png
完成安装。 一切正常了。
Next, run dnvm to verify that your terminal understands this command. If it does not, run the command source dnvm.sh to link it, then try running dnvm again. You should see something like this:
DSC0005.png
  
使用Yemoman 创建Asp.net 项目
  Mac 上 Asp.net 环境搭建好了以后,自己手动去开始一个 Asp.net 项目,是比较繁琐的。 Yeoman 上已经有 Asp.net 的 generator.
如果没有 Yeoman 先安装 Yeoman, Yeoman 的介绍: http://yeoman.io/ Yeoman下面有各种项目基础框架的generator

> npm install -g yo
  
安装 Asp.net generator
> npm install -g generator-aspnet
  
使用 yeoman 开启一个 Asp.Net 项目
> yo aspnet
  
这里使用 Nancy 框架, Nancy的介绍: http://nancyfx.org/ 一个轻量级的 .Net Web Framework
选择 Nancy ASP.Net Application
DSC0006.png
同时给一个项目名字,这里用了 NacyApp
DSC0007.png
项目基础文件框架就生产了。
进入 NacyApp 目录
执行
dnu restore
  
加载 依赖
DSC0008.png
如果 dnu 命令执行失败, commond not found.
执行命令:
source dnvm.sh
  
如果执行 dnu restore 出现 http://nuget.org/api/v2/ 取依赖包找不到的问题,切换一下源再试试,有两个可用的源:
1. https://www.myget.org/F/aspnetmaster/api/v2/
2. https://www.myget.org/F/aspnetvnext/api/v2/
例如:
dnu restore -s "https://www.myget.org/F/aspnetmaster/api/v2"
  
可以使用 core visual studio 打开工程,开始写程序。
DSC0009.png
然后 dnx . kestrel 开始你的 NacyApp 就可以了
DSC00010.png
DSC00011.png
这里有个有意思的事情,在terminal 里执行了 dnx . kestrel 后,如果想退出, 执行 ctrl+c 了以后,看到 terminal 没有反应,在浏览器里刷新一下页面, terminal 会出一个错误, 就退出了。

  
原博客地址:http://zhangsichu.com/blogview.asp?Content_Id=151
                  http://zhangsichu.com/blogview.asp?Content_Id=153

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-157969-1-1.html 上篇帖子: 没有了 下篇帖子: Mac OS 10.6(Snow Leopard)编译Android源代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表