Recognize. NET Core
The previous article introduced. NET new eco-environment: including the . NET Framework,. NET Core, Xamarin Troika
where the. NET Framework is a proprietary development framework based on the Windows platform.
. NET core can be developed and deployed on systems such as Window,macos,linux, and can be used in hardware devices, cloud services, and embedded/IoT scenarios.
Xamarin is used to build mobile apps, including iOS, OS X, Android, and more.
This article focuses on how to build a. NET core development environment on multiple platforms.
2. Building a Windows-based. NET Core development Environment
(1) Development tools: Visual Studio 2017/2015, Visual Studio Code
(2) VS2017 development environment: The use of Vs2017 development environment is very simple, VS2017 installed, has integrated support. NET Core Run All components
A. Download install vs: VS2017 official vs Code 1.8 Chinese version
B. Create a. NET Core app : Create a. NET core-based application, open VS2017, create a project such as:
It is important to note that:. NET core When you select the underlying standard framework library, the minimum version can only select the framework 4.5, the previous version is not supported.
c. Encode, debug, run. this is similar to using the. NET Framework to create a Windows environment-based. NET application. As follows:
(3) Use . NET Command Line Interface (CLI) To create a project , you can also use the command line to create a. NET core project, in addition to vs.
A. Install the. NET Core SDK for Windows. To create a project using the command line, first install the. NET Core SDK for Windows, the official 64-bit 32-bit
B. Create the project , here are some common commands (the following commands also apply to MacOS, Linux):
Command |
Description |
dotnet New |
Initializes a valid project for a class library or console application using the C # language. |
dotnet Restore |
Restores the dependencies that are defined in the Project.json file for the specified project. A dependency is typically a NuGet package that you use in your application. |
dotnet Build |
Generate Your code! This command generates intermediate language (IL) binaries that apply to your project. If the project is a console application, the resulting output is executable and you can run it immediately. By default, the build command outputs the generated assembly and executable file (if applicable) to the bin directory of the calling location directory. |
dotnet Test |
If you do not support running tests, the appropriate tool does not appear. This command allows you to run a set of tests using the run program specified in the Project.json file. Currently supports XUnit and NUnit test run programs. |
dotnet Publish |
Publishes the application running on the target computer. |
Dotnet Pack |
The pack command will package your project as a NuGet package. After you export a set of nupkg files, you can upload them to your source, or use the local folder overrides for the restore operation. |
Dotnet Run |
The Run command compiles and runs your application. You can treat it as a ctrl+f5 simulation without Visual Studio.
|
In addition to the commands with packages, you have the option to add additional commands as tools in Project.json and restore them. Packaged as NuGet packages, they provide an extensibility model that fits and is easy to use and understand.
Below we try to use the command line to create a console application
Run-cmd, create the directory, open the directory, and create the. NET Core Console application as follows:
mkdir DOTNETCORETESTCD e:\DotnetCoreTestdotnet New Console
Displays the creation of the console application successfully.
C. Commissioning, operation
Then use the dotnet Restore and dotnet run commands
dotnet Restoredotnet Run
You can see the results of the run. Here is the console application directory created by command line, as we created with VS
For more information about command-line tools, refer to the: NET Core command-line interface tool
3. Build Linux -based. NET Core development Environment
(1) Development tools: Visual Studio Code (cross-platform development tools, support for Windows, Linux, MacOS, etc.)
(2) Development environment Construction: Please refer to the previous Article Linux section: build cross-platform. NET development environment (Windows/mac OS x/linux)
4, based on
MacOSBuild the. NET Core Development environment
(1) Development tools: Visual Studio Code (cross-platform development tools)
(2) Development environment construction
A. Install MacOS 10.11 or higher (64-bit)
B. Install the latest version of OpenSSL, or you can use: Homebrew.
C. Install the. NET Core SDK for Mac OS,
D. Developing and testing code using visual Studio for MAC 2017
(3) Visual Studio for Mac, here's a brief look at Visual Studio for Mac 2017 using
A.
B. Create and run
Figure 1, running the main interface
Figure 2, creating the project
Figure 3, the Code interface
Figure 5, the familiar solution manager
Figure 6, run the MVC project
5. Summary
This article introduces the development environment of. NET core in Windows, Linux, MacOS platforms, and if you just create a. NET core application that runs under the WINDWOS system, the. NET Framework will be the best choice. If you want to take into account cross-platform development, cross-platform deployment, using. NET core is your best choice.
NET Framework,. NET Core, Xamarin