標籤:
視窗+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程式