windows系統下的第一個console程式

來源:互聯網
上載者:User

標籤:

視窗+r 鍵,輸入cmd,開啟一個命令列視窗

切換到你的目標目錄

輸入 dotnet new

dotnet會自動幫你建立3個檔案。

NuGet.Config檔案主要定義了NuGet擷取nupkg包時的伺服器位址,具體內容如下

<?xml version="1.0" encoding="utf-8"?><configuration>  <packageSources>    <!--To inherit the global NuGet package sources remove the <clear/> line below -->    <clear />    <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />    <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />  </packageSources></configuration>

Program.cs包含了應用的進入點,只簡單的輸出了經典的“Hello world!”具體內容如下

using System;namespace ConsoleApplication{    public class Program    {        public static void Main(string[] args)        {            Console.WriteLine("Hello World!");        }    }}

project.json是項目的設定檔,配置了依賴的包、運行環境等資訊。

關鍵的依賴關係dependencies需要注意,跟dnx時有了很大區別

具體內容如下

{    "version": "1.0.0-*",    "compilationOptions": {        "emitEntryPoint": true    },    "dependencies": {        "NETStandard.Library": "1.0.0-rc2-23811"    },    "frameworks": {        "dnxcore50": { }    }}

然後使用命令 dotnet restore來還原依賴的包

結果出錯:

error: The HTTP request to ‘GET https://api.nuget.org/v3-flatcontainer/system.reflection/index.json‘ has timed out after

100000ms.

error: Failed to retrieve information from remote source ‘https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-cor

e/nuget/v3/flatcontainer/system.reflection/index.json‘.

error: The HTTP request to ‘GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-core/nuget/v3/flatcontainer/s

ystem.reflection/index.json‘ has timed out after 100000ms.

error: Failed to retrieve information from remote source ‘https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-cor

e/nuget/v3/flatcontainer/system.reflection/index.json‘.

error:   The HTTP request to ‘GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-core/nuget/v3/flatcontainer

/system.reflection/index.json‘ has timed out after 100000ms.

搞不懂咋搞的,竟然linux下很正常,自家的windows搞不定。

windows系統下的第一個console程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.