ubuntu 16.04下用.NET Core写C#程序
来源:互联网 发布:winaip阅读器软件下载 编辑:程序博客网 时间:2024/06/13 07:41
2017 微软一个比较大的动作就是.Net core2.0了,微软出的这个框架野心很大:它可以让用户在几乎所有的PC终端用C#编写自己的应用程序。在win/linux/mac三大主流操作系统通吃之后,.Net core居然也支持Docker!
本文试着在ubuntu 16.04运行自己的C#程序,其他操作系统包括Windows,MacOS和Docker上的教程见官网:.Net Core
首先注入密钥更新系统:
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B02C46DF417A0893sudo apt-get update
然后安装.Net SDK:
sudo apt-get install dotnet-dev-2.0 #安装最新2.0预览版
接着创建你的项目,一般第一个项目就是黑框框打印”hello world”,那我们就把项目类型指定为”console”,类似于vs中的控制台项目。
dotnet new console -o firstapp
执行完这条命令后,打印如下:
Welcome to .NET Core!---------------------Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.Telemetry--------------The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.Configuring...-------------------A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.Decompressing 100% 5047 msExpanding 100% 8946 msGetting ready...The template "Console Application" was created successfully.Processing post-creation actions...Running 'dotnet restore' on firstapp/firstapp.csproj...Restore succeeded.
执行tree ..命令,查看项目结构,可以看到:
..└── firstapp ├── firstapp.csproj ├── obj │ ├── firstapp.csproj.nuget.g.props │ ├── firstapp.csproj.nuget.g.targets │ └── project.assets.json └── Program.cs
在你的Program.cs中编写你的程序,这里其实已经自动生成了”Hello World!”的打印代码。
然后执行以下命令,程序就会在终端打印”hello world”:
cd firstappdotnet restoredotnet run
在首次运行时候会创建一个Nugut.Config文件,详细打印如下:
# dotnet restore Restoring packages for /home/Csharp/firstapp/firstapp.csproj... Lock file has not changed. Skipping lock file write. Path: /home/Csharp/firstapp/obj/project.assets.json Restore completed in 93.44 ms for /home/Csharp/firstapp/firstapp.csproj. NuGet Config files used: /root/.nuget/NuGet/NuGet.Config Feeds used: https://api.nuget.org/v3/index.json /root/.dotnet/NuGetFallbackFolder
阅读全文
0 0
- ubuntu 16.04下用.NET Core写C#程序
- Docker下用.NET Core写C#程序
- CentOS7下用.NET Core写C#程序
- .NET Core程序发布到Ubuntu系统
- Ubuntu 16.04 安装 .NET Core
- Ubuntu 16.04下ASP.NET Core+ MySql + Dapper在 Jexus、nginx 下的简单测试
- ASP.NET Core 1.0 on Ubuntu 16.04
- Ubuntu安装.net core
- 怎样在ubuntu下写c++程序
- .NET CORE实践(1)--Ubuntu下的Hello World
- ubuntu下让崩溃的程序产生core dump文件
- Core C# and .NET
- C# .net core 入门
- .net core 2.0 下,用C#自创实现MysqlHelper的ExecuteDataTable 功能[2017-10-30]
- VB.NET程序目录下写日志
- 用记事本写C#程序
- 手把手教你用.NET Core写爬虫
- 为什么大多数asp.net程序都是用C#来写的呢?
- Matlab画折线图(线上有点)
- 经典DP——最长公共子序列
- Gym
- UVA 10954 Add All
- Qt日志输出至文件
- ubuntu 16.04下用.NET Core写C#程序
- POJ 2492A Bug's Life
- windows端ftp服务端和客户端配置
- 数据结构-AVL树
- 早起21天
- Canvas---七巧板
- Aizu
- 百万数据进行查询与排序
- 请假管理系统