. NET Core Development Requirements
- Visual Studio Update3
- . NET Core 1.0 for Visual Studio (DOTNETCORE.1.0.0-SDK.PREVIEW2)
the specific shift: https://www.microsoft.com/net/core#windows
Coding create a new. NET Core Console ProjectProject Template Description
- Class library (Basic libraries)
- Console Application (console application)
- ASP. NET Core (Web application)
The. NET Framework4.5 above is familiar to everyone, but. NET core is actually not related to the. NET Framework, and it is believed that subsequent versions of the SDK will solve this problem. You can now select only the. NET Framework of 4.5 or more to see 3 types of projects.
Type some codeRunA talk about publishingThe. NET core is divided into two types of applications, namely:
- Portable applications (Portable application)
- self-contained application (self-hosted application) Portable Applications (portable application)
This is similar to the existing. NET Framework approach, requiring that the target host be installed with the. NET core runtime, compared to the current situation where the machine is required to install the. NET Framework.
I think everyone is familiar with this approach, and Microsoft has the. NET core runtime on different platforms (operating systems).
The. NET core runtime is the same level but not the same as the. NET Framework.
Advantages
- Easy to transplant
- published content is small Disadvantages
- you need to install the. NET Core Runtime self-contained application (self-hosted application)
When it happens, it's cool and one of my favorite ways to publish.
This way, the runtime is packaged with the program, which means that the target machine does not need to install the. NET core Runtime.
Advantages
- Simple Deployment Disadvantages
- post content is largeNotes
This is not the case for. NET Native, and there is no performance boost either because our program is IL or requires JIT compilation in the CLR, just packaging the core CLR in, which is understood to provide the green version of the. NET Core Runtime, A corresponding platform executable program is then provided to load the call.
References: Https://docs.microsoft.com/zh-cn/dotnet/articles/core/app-types
Publish your AppPublishing using the (CLI) command lineRelease: Portable Applications (portable application)Run "CMD" (Command Prompt)
Navigate to Project Path
Using the Publish command
So the release is done.
PS: If publishing fails, perform dotnet restore first or build using Visual Studio.
dotnet Publish has a number of options, in the following format:
-F,--framework [FID]
Specifies the run framework, such as netcoreapp1.0,net45,net451, which is specified by the framework node in the Project.json.
-R,--runtime [RID]
Specifies the application runtime (self-hosted app), which will package the core CLR of the specified platform.
Format: [OS]. [Version]-[arch]
Examples: win7-x64, win7-x86, win10-x64, Win10-x86, rhel.7.0-x64, ubuntu.14.04-x64, osx.10.10-x64, etc.
References: Https://docs.microsoft.com/zh-cn/dotnet/articles/core/rid-catalog
-B,--build-base-path [DIR]
Specifies the output path root.
-o,–output
Specifies the specific output path, which is mated with the "-B" command.
Default path:
- Portable applications:./bin/[configuration]/[framework]//app
- self-contained application:./bin/[configuration]/[framework]/[runtime]/app
--version-suffix [Version_suffix]
Replace the * in the dependent package version number in the "Project.json" file.
-C,--configuration [debug| Release]
Release configuration, this everyone knows, the default is: Debug.
References: Https://docs.microsoft.com/zh-cn/dotnet/articles/core/tools/dotnet-publish
publishing with Visual StudioRight-click publish, optional parameter please refer to above.
Release: Self-contained Application (self-hosted app)Modify "Project.json"Delete the configuration of "type": "Platform" in the "MICROSOFT.NETCORE.APP" node
Add the corresponding platform in the "Runtime" node
The modified "Project.json" is as follows:
Publishing using the CLI or Visual Studio
CLI command:
dotnet Restore
dotnet Publish–r [win10-x64 | ubuntu.16.04-x64]–c release
References: https://docs.microsoft.com/zh-cn/dotnet/articles/core/deploying/index#self-contained-applications
RunPortable Applications (portable application)CD to the Publish directory, and then run the following command
Dotnet ConsoleApp1.dll
self-contained application (self-hosted application)Directly open the executable file
WindowsUnder direct double-click on "ConsoleApp1.exe" you understand.
UbuntuInstall UbuntuCurrently the official support version is
- Ubuntu 14.04 LTS (Long supported version)
- Ubuntu 15.04 LTS (Long supported version) This I did not publish success
- Ubuntu 16.04 LTS (Long supported version)
The author uses 16.04, the image file is around 1.4GB.
: Http://releases.ubuntu.com/16.04/ubuntu-16.04-desktop-amd64.iso
The author uses Hyper-V as the system comes with the virtual machine software.
Installation of the specific process is not posted, many online, say a note.
When using Hyper-V to install Ubuntu, the last step will be stuck for a long time, you can force a reboot (preferably wait a few minutes in a forced restart), of course, and so on, he will be good for a long time.
(The general meaning is: Please delete the installation media, press ENTER) However, I have already separated the virtual optical drive.
Copy Published contentI'm using a virtual optical drive image.
running self-hosted appsTo set execution permissions for an execution program
Using the command line to execute
is not very cool, no installation of anything, you can run directly.
Running Portable ApplicationsFirst you have to install the. NET Core Runtime Environment
References: Https://www.microsoft.com/net/core#ubuntu
After the installation is complete, enter "Dotnet--info" to test whether the installation was successful.
OK, Next we'll run.
Navigate to the directory and run "dotnet ConsoleApp1.dll"
PS: Remember not to use "dotnet run" this command, otherwise you will be prompted to find "Project.json", input will be executed after a certain thing for some reason did not intercept the diagram.
next? And then I'll share the same. How to write class libraries and applications that support multiple platforms in. NET Core.
For example, writing a class library supports 4.5, and. Netstandard 1.6.