First ASP.NET Core Application on a Mac Using Visual Studio Code

一直但愿能够在mac上直接编写webapp (用C#)如今终于伴随着 core 世界美好了,不须要用pd windows了 nice。 html

Visual studio code 更新1.1版本了

怀着激动的心情尝试一下在mac上运行asp.net5 core application node

首先你要下载 visual studio code git

https://www.visualstudio.com/zh-cn/products/code-vs.aspx github

安装ASP.NET 5 DNX(.NET执行环境)

dnx asp.net5 core的核心 web

github:https://github.com/aspnet/home#os-x macos

官网:https://www.microsoft.com/net npm

osx:https://www.microsoft.com/net/core#macosx json

  1. Install pre-requisites

为了使用.NET的核心,你须要安装OpenSSL版本的更新 bootstrap

http://brew.sh/index_zh-cn.html windows

安装完成之后进入下一步:

        brew update

        brew install openssl

        brew link --force openssl

  1. Install .NET Core SDK

在你开始以前删除全部之前的版本,从你的系统中的网络核心,使用这个脚本。

https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/uninstall/dotnet-uninstall-pkgs.sh

官方安装包安装的最好方式。在OS X核心是利用官方PKG包。这个安装程序将安装这些工具并将它们放在你的路径上。

https://go.microsoft.com/fwlink/?LinkID=798400

  1. Initialize some code

如今能够写一个hello word 了。

mkdir hwapp :建立文件夹

cd hwapp :跳转路径

dotnet new :建立一个C#项目到hwapp文件夹

  1. Run the app

dotnet restore:恢复在project.json文件指定的包

dotnet run:执行应用

  1. and you're set!

你如今能够去github上看源代码了(无论你看不看 我反正没看)

What's Yeoman?

若是你来从Visual Studio .NET IDE 走过来的人,你会想,"是否有文件>新建> ASP.NET项目模板?"。 Visual Studio Code是基于文件的代码编辑器,它使你能够只打开一个文件,并开始编辑。 所以,咱们将须要一些外部的帮助,让咱们的ASP.NET项目模板加载。

Yeoman是一个流行的命令行工具,还提供了一个基本的ASP.NET模板开始。 Yeoman可以使用NPM安装,这意味着你将须要安装Node.js(https://nodejs.org/en/download/)。

除了Yeoman,咱们还须要一些其余的辅助工具,如ASP.NET GeneratorGrunt task runner and Bower。 您能够在一个命令执行此操做。 在命令提示符处键入如下命令,而后按Enter键:

npm install –g yo grunt-cli generator-aspnet bower(报错)

看到这个就正常了!不要用node.js 4.4.4用最新的6.2.0

总结以下:

建立Web应用程序

让咱们经过scaffold建立一个新的ASP.NET 5 Web应用程序。

  1. 打开命令提示符,并要在其中建立新的Web应用程序导航到该位置

    cd hwapp

2.在命令提示符下输入如下命令 


yo aspnet

控制台应用程序

Web应用程序

网络应用基础(没有会员/验证)

网页API应用程序

nancy ASP.NET应用程序

类库

单元测试项目

咱们选择(网络应用基础(没有会员/验证))

继续选择bootstrap 3.3.6

输入项目名称(hwapp)

完成后会有以下提示:

 

Your project is now created, you can use the following commands to get going

cd "hwapp"

dotnet restore

dotnet build (optional, build will also happen when it's run)

dotnet run

若是建立项目报上图错误

一般yeoman错误从新安装what's yeoman 步骤。

正常后以下图:

相关文章
相关标签/搜索