2017-05-13更新,可用,本身傻逼纔會在Linux下用微軟的爛玩意!!!php
最新參考網頁:html
參考網頁:linux
抱歉,微軟的東西比較噁心,網址居然變了,一部分失效了。更改。若有異常,請自行解決。git
由於開發速度太慢,致使老大看不過去了,直接購買了別人的網站,以前使用PHP開發的,別人的源碼是ASP.NET的,所幸對方提供源碼,要給對方升級?github
一直使用Linux Deepin操做系統,已經兩三年了,沒有在電腦上存在Windows系統了,忽然要裝個盜版windows系統,實在不情願,折騰系統太費勁了。遂用 VS Code和ASP.NET Core一塊兒,在Deepin下,能否更好一點呢?就這樣搭建吧。web
到這個網頁,點擊下載這個文件,假設下載到 Desktop 桌面。面試
因爲默認不支持 deepin格式,須要修改一下這個腳本。npm
$ gedit ~/Desktop/dotnet-install.sh
搜素 debian
, debian.8
前,照瓢畫葫蘆,加入 「deepin.15.4"的內容。json
"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/
解釋gulp
接下來就是創建連接了
$ sudo ln -s /opt/dotnet/dotnet /usr/local/bin
dotnet --version
通常會看到版本號,跟上方的 1.0.4
一致。
cd mkdir www cd www mkdir test cd test dotnet 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 templates Segmentation 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.1 dotnet new mvc --framework netcoreapp1.1 dotnet new --help
輸入以下命令,
$ dotnet new mvc --auth None --framework netcoreapp1.1
新建並初始化,
$ dotnet restore $ dotnet run
本小點內容主要參考該書.
sudo npm install -g yo bower grunt-cli gulp sudo npm install -g generator-aspnet
解釋
cd ~/www yo aspnet
解釋
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 going cd "WebLW" dotnet restore dotnet 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/WebLW bower install
若是沒有報錯,繼續使用上面提示的內容
cd ~/www/WebLW dotnet restore dotnet build dotnet ef database update dotnet run
根據提示進入 http://localhost:5000/ 應該能夠看到以下的界面了。
這個比較傻瓜了,直接使用命令便可
sudo apt-get install vscode -y
其餘插件安裝能夠自行百度。 我如今安裝的插件有
如今直接使用命令 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": true 6. Restart Visual Studio Code.
sudo apt-get install mono-complete
算是安裝成功啦。
到:https://github.com/OmniSharp/omnisharp-roslyn/releases/ 下載最新的,當前 v1.9-beta14,解壓縮後,放在 ~/.vscode文件夾下
cd ~/.vscode mkdir omnisharp cd omnisharp cp /path/to/omnisharp-mono.tar.gz ./ tar zxvf omnisharp-mono.tar.gz ls
解釋 會在這個文件夾下發現 ~/.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 }
解釋
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
這裏再也不廢話,有問題,歡迎下面留言。
代碼複製於 http://download.csdn.net/detail/u013003382/9498661 某章節,下面試着在 deepin 下熟悉 C# 和 ASP.NET core 的通常編寫過程。(待續)