官术网_书友最值得收藏!

Installing .NET Core on Linux

To show the cross-platform feature of .NET Core, let's set up a .NET Core development environment on Ubuntu 17.04 desktop version. Before installing Visual Studio Code, let's install .NET Core on the Ubuntu OS. First, you need to do a one-time registration of the Microsoft Product feed, which is done by registering the Microsoft signature key before adding the Microsoft Product feed to the system:

  1. Launch the system terminal and run the following commands to register the Microsoft signature key:
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
  1. Register the Microsoft Product feed with this command:
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-zesty-prod zesty main" > /etc/apt/sources.list.d/dotnetdev.list
  1. To install .NET Core SDK and the other components required to develop .NET Core applications on the Linux operating system, run the following commands:
sudo apt-get update
sudo apt-get install dotnet-sdk-2.0.0
  1. The commands will update the system and you should see the Microsoft repository from earlier added among the list of repositories where Ubuntu will attempt to get updates from. After the update, the .NET Core tool will be downloaded and installed on the system. The information displayed on your terminal screen should be similar to what is in the following screenshot:
  1. When the installation completes, create a new folder inside the Documents folder and name it testapp. Change the directory to the newly created folder and create a new console application to test the installation. See the following commands, and the screenshot for the outcome of the commands:
cd /home/user/Documents/testapp
dotnet new console

This gives the following output:

  1. You would see on the terminal as .NET Core is creating the project and the required files. After the project has been successfully created, Restore succeeded will be displayed on the terminal. Inside the testapp folder, an obj folder, Program.cs, and testapp.csproj files would have been added by the framework.
  2. You can proceed to run the console application using the dotnet run command. This command will compile and run the project before displaying Hello World! on the terminal.
主站蜘蛛池模板: 汉寿县| 普宁市| 宣化县| 横山县| 徐闻县| 普定县| 阜平县| 海安县| 河南省| 西平县| 富顺县| 惠州市| 郑州市| 柘荣县| 枣阳市| 仙桃市| 九龙坡区| 濮阳市| 祁连县| 阿勒泰市| 抚顺县| 喀喇沁旗| 娱乐| 泸西县| 宁乡县| 将乐县| 鄂托克旗| 如皋市| 聂拉木县| 揭阳市| 岢岚县| 团风县| 长寿区| 开原市| 青铜峡市| 蕉岭县| 贡山| 中江县| 通化县| 梓潼县| 新绛县|