In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to install Microsoft's .NET Core SDK in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
.net Core is a free, cross-platform and open source development framework provided by Microsoft, which can build desktop applications, mobile applications, web applications, Internet of things applications and game applications. If you are a dotnet developer on the Windows platform, you can easily set up any development environment for Linux and Unix-like operating systems using .NET core. This step-by-step guide article explains how to install the .NET Core SDK in Linux and how to develop * * applications using .NET.
Install .NET Core SDK in Linux
.net Core supports GNU/Linux, Mac OS and Windows systems and can be installed and run on major GNU/Linux operating systems, including Debian, Fedora, CentOS, Oracle Linux, RHEL, SUSE/openSUSE and Ubuntu. At the time of writing this tutorial, the * version is 2.2.
To install the .NET Core SDK on a Debian 9 system, follow these steps.
First, you need to register the Microsoft key, then add the .NET source repository address, and run the following command:
$wget-qO- https://packages.microsoft.com/keys/microsoft.asc | gpg-- dearmor > microsoft.asc.gpg$ sudo mv microsoft.asc.gpg / etc/apt/trusted.gpg.d/$ wget-Q https://packages.microsoft.com/config/debian/9/prod.list$ sudo mv prod.list / etc/apt/sources.list.d/microsoft-prod.list$ sudo chown root:root / etc/apt/trusted.gpg.d/microsoft.asc.gpg$ sudo chown root:root / Etc/apt/sources.list.d/microsoft-prod.list
After registering the key and adding the repository source, you can install .NET SDK with the following command:
$sudo apt-get update$ sudo apt-get install dotnet-sdk-2.2
Installed on Debian 8 systems:
Add Microsoft key and add .NET warehouse source:
$wget-qO- https://packages.microsoft.com/keys/microsoft.asc | gpg-- dearmor > microsoft.asc.gpg$ sudo mv microsoft.asc.gpg / etc/apt/trusted.gpg.d/$ wget-Q https://packages.microsoft.com/config/debian/8/prod.list$ sudo mv prod.list / etc/apt/sources.list.d/microsoft-prod.list$ sudo chown root:root / etc/apt/trusted.gpg.d/microsoft.asc.gpg$ sudo chown root:root / Etc/apt/sources.list.d/microsoft-prod.list
Install the .NET SDK:
$sudo apt-get update$ sudo apt-get install dotnet-sdk-2.2
Installed on Fedora 28 systems:
Add Microsoft key and add .NET warehouse source:
$sudo rpm-- import https://packages.microsoft.com/keys/microsoft.asc$ wget-Q https://packages.microsoft.com/config/fedora/27/prod.repo$ sudo mv prod.repo / etc/yum.repos.d/microsoft-prod.repo$ sudo chown root:root / etc/yum.repos.d/microsoft-prod.repo
Now you are ready to install the .NET SDK:
$sudo dnf update$ sudo dnf install dotnet-sdk-2.2
Under the Fedora 27 system:
Add the Microsoft key and add the .NET warehouse source with the following command:
$sudo rpm-- import https://packages.microsoft.com/keys/microsoft.asc$ wget-Q https://packages.microsoft.com/config/fedora/27/prod.repo$ sudo mv prod.repo / etc/yum.repos.d/microsoft-prod.repo$ sudo chown root:root / etc/yum.repos.d/microsoft-prod.repo
Then install the .NET SDK with the following command:
$sudo dnf update$ sudo dnf install dotnet-sdk-2.2
On CentOS/Oracle versions of Linux systems:
Add Microsoft key and add .NET warehouse source to make it available:
$sudo rpm-Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
Update the source repository and install the .NET SDK:
$sudo yum update$ sudo yum install dotnet-sdk-2.2
On openSUSE Leap version of the system:
Add a key to make the warehouse source available, and install the necessary dependency packages with the following command:
$sudo zypper install libicu$ sudo rpm-- import https://packages.microsoft.com/keys/microsoft.asc$ wget-Q https://packages.microsoft.com/config/opensuse/42.2/prod.repo$ sudo mv prod.repo / etc/zypp/repos.d/microsoft-prod.repo$ sudo chown root:root / etc/zypp/repos.d/microsoft-prod.repo
Update the source repository and install .NET SDK with the following command:
$sudo zypper update$ sudo zypper install dotnet-sdk-2.2
On Ubuntu 18.04 LTS version of the system:
Register Microsoft's key and .NET Core warehouse source with the following command:
$wget-Q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb$ sudo dpkg-I packages-microsoft-prod.deb
Make the Universe repository available:
$sudo add-apt-repository universe
Then, install the .NET Core SDK with the following command:
$sudo apt-get install apt-transport-https$sudo apt-get update$ sudo apt-get install dotnet-sdk-2.2
On Ubuntu 16.04 LTS version of the system:
Register Microsoft's key and .NET Core warehouse source with the following command:
$wget-Q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb$ sudo dpkg-I packages-microsoft-prod.deb
Then install the .NET core SDK:
$sudo apt-get install apt-transport-https$ sudo apt-get update$ sudo apt-get install dotnet-sdk-2.2 create your * applications
We have successfully installed the .NET Core SDK on the Linux machine. It's time to create * applications using dotnet.
For the next purpose, we will create an application called ostechnixApp. To do this, simply run the following command:
$dotnet new console-o ostechnixApp
Sample output:
Welcome to .NET Core: https://aka.ms/dotnet-docsUse 'dotnet-- help' to see available commands or visit: https://aka.ms/dotnet-cli-docs Telemetry-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. Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry ASP.NET Core-Successfully installed the ASP.NET Core HTTPS Development Certificate.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.For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.Getting ready...The template "Console Application" was created successfully. Processing post-creation actions...Running 'dotnet restore' on ostechnixApp/ostechnixApp.csproj...Restoring packages for / home/sk/ostechnixApp/ostechnixApp.csproj...Generating MSBuild file / home/sk/ostechnixApp/obj/ostechnixApp.csproj.nuget.g.props.Generating MSBuild file / home/sk/ostechnixApp/obj/ostechnixApp.csproj.nuget.g.targets.Restore completed in 894.27 ms for / home/sk/ostechnixApp/ostechnixApp.csproj. Restore succeeded.
As the output above shows, .NET has created a console-type application for us. The-o parameter creates a directory called "ostechnixApp" that contains the files necessary to store the application's data.
Let's change to the ostechnixApp directory and see what's in it.
$cd ostechnixApp/$ lsobj ostechnixApp.csproj Program.cs
You can see that there are two files named ostechnixApp.csproj and Program.cs, and a directory called obj. By default, the Program.cs file contains "Hello World" program code that can be run in the console. You can look at this code:
$cat Program.cs using System; namespace ostechnixApp {class Program {static void Main (string [] args) {Console.WriteLine ("Hello World!");}
To run this application, you can simply use the following command:
$dotnet runHello World!
It's simple, isn't it? Yes, it's that simple. Now you can write your own code in the Program.cs file and execute it as shown above.
Alternatively, you can create a new directory, such as the mycode directory shown in the example, with the following command:
$mkdir ~ / .mycode$ cd mycode/
Then run the following command to make it your new development environment directory:
$dotnet new console
Sample output:
The template "Console Application" was created successfully. Processing post-creation actions...Running 'dotnet restore' on / home/sk/mycode/mycode.csproj...Restoring packages for / home/sk/mycode/mycode.csproj...Generating MSBuild file / home/sk/mycode/obj/mycode.csproj.nuget.g.props.Generating MSBuild file / home/sk/mycode/obj/mycode.csproj.nuget.g.targets.Restore completed in 331.87 ms for / home/sk/mycode/mycode.csproj. Restore succeeded.
The commands on the create two files named mycode.csproj and Program.cs and a directory called obj. Open the Program.cs file with your favorite editor, delete or modify the original "hello world" code snippet, and then write your own code.
After writing the code, save, close the Program.cs file, and then run the application with the following command:
$dotnet run
To see the version of the .NET core SDK installed, you can simply run:
$dotnet-version2.2.101
For help, run:
$dotnet-help uses Microsoft's Visual Studio Code editor
To write code, you can choose any editor you like. Microsoft also has its own editor that supports .NET, called "Microsoft Visual Studio Code". It is an open source, lightweight, powerful source code editor. With built-in support for JavaScript, TypeScript, and Node.js, and rich extensions for other languages (such as C++, C#, Python, PHP, Go) and runtime tenses (such as .NET and Unity), it has formed a complete ecosystem. It is a cross-platform code editor, so it can be used in Microsoft's Windows, GNU/Linux and Mac OS X systems.
Telemetry
By default,. NET core SDK collects user usage data, which is called Telemetry. The collected data is anonymous and shared with its development team and community in accordance with the Creative Commons signature license. So the .NET team will know how these tools are being used and then make statistical decisions to improve the product. If you don't want to share your usage information, you can use the handy shell tool to set the environment variable parameter called DOTNET_CLI_TELEMETRY_OPTOUT to 1 or true, so you can simply turn off this feature.
Thank you for reading! This is the end of the article on "how to install Microsoft's .NET Core SDK in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.