加入收藏 | 设为首页 | 会员中心 | 我要投稿 东莞站长网 (https://www.0769zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

如何在Linux中安装微软的 .NET Core SDK

发布时间:2019-01-30 13:05:18 所属栏目:Windows 来源:Sk
导读:.NET Core 是微软提供的免费、跨平台和开源的开发框架,可以构建桌面应用程序、移动端应用程序、网络应用程序、物联网应用程序和游戏应用程序等。如果你是 Windows 平台下的 dotnet 开发人员的话,使用 .NET core 可以很轻松就设置好任何 Linux 和类 Unix

更新源仓库,安装 .NET SDK,命令如下:

  1. $ sudo zypper update
  2. $ sudo zypper install dotnet-sdk-2.2

Ubuntu 18.04 LTS 版本的系统上:

注册微软的密钥和 .NET Core 仓库源,命令如下:

  1. $ wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
  2. $ sudo dpkg -i packages-microsoft-prod.deb

使 Universe 仓库可用:

  1. $ sudo add-apt-repository universe

然后,安装 .NET Core SDK ,命令如下:

  1. $ sudo apt-get install apt-transport-https
  2. $sudo apt-get update
  3. $ sudo apt-get install dotnet-sdk-2.2

Ubuntu 16.04 LTS 版本的系统上:

注册微软的密钥和 .NET Core 仓库源,命令如下:

  1. $ wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
  2. $ sudo dpkg -i packages-microsoft-prod.deb

然后安装 .NET core SDK:

  1. $ sudo apt-get install apt-transport-https
  2. $ sudo apt-get update
  3. $ sudo apt-get install dotnet-sdk-2.2

创建你的第一个应用程序

我们已经成功的在 Linux 机器中安装了 .NET Core SDK。是时候使用 dotnet 创建第一个应用程序了。

接下来的目的,我们会创建一个名为 ostechnixApp 的应用程序。为此,可以简单的运行如下命令:

  1. $ dotnet new console -o ostechnixApp

示例输出:

  1. Welcome to .NET Core!
  2. ---------------------
  3. Learn more about .NET Core: https://aka.ms/dotnet-docs
  4. Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
  5.  
  6. Telemetry
  7. ---------
  8. The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
  9.  
  10. Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
  11.  
  12. ASP.NET Core
  13. ------------
  14. Successfully installed the ASP.NET Core HTTPS Development Certificate.
  15. To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
  16. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
  17. Getting ready...
  18. The template "Console Application" was created successfully.
  19.  
  20. Processing post-creation actions...
  21. Running 'dotnet restore' on ostechnixApp/ostechnixApp.csproj...
  22. Restoring packages for /home/sk/ostechnixApp/ostechnixApp.csproj...
  23. Generating MSBuild file /home/sk/ostechnixApp/obj/ostechnixApp.csproj.nuget.g.props.
  24. Generating MSBuild file /home/sk/ostechnixApp/obj/ostechnixApp.csproj.nuget.g.targets.
  25. Restore completed in 894.27 ms for /home/sk/ostechnixApp/ostechnixApp.csproj.
  26.  
  27. Restore succeeded.

正如上面的输出所示的,.NET 已经为我们创建一个控制台类型的应用程序。-o 参数创建了一个名为 “ostechnixApp” 的目录,其包含有存储此应用程序数据所必需的文件。

(编辑:东莞站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!