.Net Core 系列之一 hello world

OS:app

  win10 企業版 中文環境工具

.Net Core:visual-studio

  切記不要裝64版本,不然可能會出現vs2017沒法生成.net core 2.0的項目spa

  dotnet-sdk-2.0.0-win-x86.exe 下載地址: https://download.microsoft.com/download/0/F/D/0FD852A4-7EA1-4E2A-983A-0484AC19B92C/dotnet-sdk-2.0.0-win-x86.exe.net

  dotnet-runtime-2.0.0-win-x64.exe  下載地址: https://download.microsoft.com/download/5/6/B/56BFEF92-9045-4414-970C-AB31E0FC07EC/dotnet-runtime-2.0.0-win-x64.exe調試

VS2017 community 15.3.3:code

  vs_community__101603913.1505015285 下載地址:https://www.visualstudio.com/zh-hans/thank-you-downloading-visual-studio/?sku=Community&rel=15 blog

若是VS2017 community 15.3.3 安裝完成後沒法新建.net core 2.0的項目,請刪除C:\Program Files\dotnet 和C:\Program Files (x86)\dotnet這兩個目錄。重啓後,而後從新安裝上面的x86版本的.Net Core。教程

拿VS2017 community 15.3.3新建.net core 2.0 項目:get

  一、新增項目:

    參考教程:https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/with-visual-studio

  二、調試項目:

    在菜單欄中,選擇「生成」 > 「生成解決方案」。 這會將程序編譯成一種中間語言 (IL),而後由實時 (JIT) 編譯器轉換成二進制代碼。

      選擇工具欄上含綠色箭頭的「HelloWorld」按鈕,從而運行程序。

  三、發佈項目:

    參考教程:https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/publishing-with-visual-studio

    生成exe:修改.csproj文件,主要是增長「<RuntimeIdentifier>win10-x64</RuntimeIdentifier>」這個設置,「<OutputType>Exe</OutputType>」這個會在添加win10-x64之後自動添加。

1 <Project Sdk="Microsoft.NET.Sdk">
2   <PropertyGroup>
3     <OutputType>Exe</OutputType>
4     <TargetFramework>netcoreapp2.0</TargetFramework>
5     <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
6   </PropertyGroup>
7 </Project>

    \bin\Release\PublishOutput目錄下就會自動生產.exe文件。

相關文章
相關標籤/搜索