windows系统下的第一个console程序
Posted draweye
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows系统下的第一个console程序相关的知识,希望对你有一定的参考价值。
窗口+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程序的主要内容,如果未能解决你的问题,请参考以下文章