article Background
Microsoft's June 26 release of Core 1.0, the garden in this area of the article is even more popular, whether from the number of articles or the enthusiasm of everyone to see, is definitely the hottest technology. I have been in touch with. NET core since the end of last year, and have been staying in the browse various posts, occasionally new projects hit a few lines of code practice. But for the core of the biggest selling point-cross-platform, has been unable to experience the actual time, because there is no contact with Linux, at all, not those commands, and even the virtual machine has not played?, want to operate on Linux on the actual operation can be how difficult. Although many articles in the garden have a tutorial, but the great God began directly on the various command code, do not understand Ah, do not know how to start ... But these are not to block their own reasons, that from the installation of the virtual machine to start step-by-step, the middle of a variety of forced to step on the pit to consult, so there is this summary record.
[Special thanks to the University dorm's base friends and architect Allen for assists! ]
a bit more nonsense, the following officially open ...
1. Activate the Hyper-V Virtual Machine management tool in Windows System (Microsoft Party is of course preferred to own things AH).
2, download the CentOS system image file, address:
Http://mirrors.aliyun.com/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-DVD-1511.iso
3. Create a virtual machine (named CentOS) in Hyper-V, set the parameters of the virtual machine, and then start the virtual machine installation system and configure the system user (default is root).
4. After successful installation, connect to CentOS, the following login request appears:
Log in to the system with the last set of accounts (I am root here) and the last logon message will be displayed when the login is successful:
5, this time the virtual machine is no network, we need to create a new network adapter, and then to the virtual machine:
A virtual switch is then added to the local network connection:
Specify an IP for the same network segment, and then restart the virtual machine. After logging in, set the network parameters, enter the command:
#vi/etc/sysconfig/network-scripts/ifcfg-eth0//Edit configuration file
According to the respective circumstances, and then press "ESC" Exit edit, enter the command ": Wq" Save this edit. Then enter the command to restart the network (really not restart the virtual machine):
# Service Network Restart
Then ping Baidu's domain name to see if it can connect to the Internet. Be sure to be able to surf the internet, because the dependent assemblies are downloaded from the Web when restore is back.
6, with the black and white screen is very bad use Ah, this time a magical tool will debut-xshell, self-download installation, and then create a new connection to the virtual machine, after the successful connection:
7, the machine is ready to complete, the next will be equipped with dotnet Core environment, that is, install an SDK, we go to the official website to download the latest, address: https://go.microsoft.com/fwlink/? linkid=809131, the downloaded file name is dotnet-dev-centos-x64.1.0.0-preview2-003121.tar.gz. There are two ways to download files in a virtual machine, the first is to use the wget command (recommended, you can feel the thrill of command operation, hhhh~), the machine needs to install wget tools. The second is to use FTP, this time need to use Xshell partner Xftp, download the installation from here to open ftp:
The use of the FTP tool is too familiar with the interface, and automatically help us to connect the virtual machine, so that the virtual machine file operation is more convenient, I am not familiar with the Linux command is simply too cool.
8, under the root of a new folder "Dotnet" used to put the SDK, and then FTP from the computer to the SDK compression package, the next to use the command decompression, open the Xshell in turn input:
# cd dotnet//Enter into the dotnet directory
# tar ZXF dotnet-dev-centos-x64.1.0.0-preview2-003121.tar.gz//Unzip files
After extracting the settings environment variable, enter the command:
# Vi/etc/profile//Open file for editing
Add the following:
Path=~/dotnet: $PATH//dotnet directory for the SDK
Export PATH
Then press "ESC" to exit the edit and enter the command ": Wq" to save this edit. Execute the following command to make the configuration take effect immediately (if not, restart the virtual machine):
# Source/etc/profile
So the environment is configured, test the "dotnet" command can be used, enter:
# dotnet--version//view dotnet version
The successful installation will print out the version number:
9, everything has only due process Ah! Create a new console program now to get some cool. In the root directory, enter the following sequence:
# mkdir Dotnetcore_app//Create Folder
# CD Dotnetcore_app//Enter file
# dotnet New//Create a new core console project
# dotnet Restore//Download the program's dependency package from NuGet
# dotnet Build//Compile Project
# dotnet Run//Running project
It's so exciting to see "Hello World" coming out of my heart.
10, next want to run a Web project to play, check the command to create a Web project if you want to install Yeoman and NPM, just do not install, just use FTP to create a locally created project to the virtual machine, and then restore:
Then build:
Then run up:
You can see that the listening Port 5000 (program default) has been opened, indicating that the program has run, with the virtual machine can access the address, but the physical machine is not able to identify the virtual machine localhost, so directly in the physical machine browser is not accessible, then how to do?
11, find program in the main method, to host the virtual machine to bind the address and port, be sure to bring the http://, or compile error.
12. Then build it again and run it again:
13, the local browser to visit the site, done:
Before and after the time spent almost a day, the above only recorded the smooth operation of the steps, too many bumps in the middle is not complete, but the most happy is finally reached their goals.
Summary
1, step by step, always see the dawn.
2, more trample pits, will let oneself more experience, impression deeper engraved.
3. Restarting the system is sometimes a very effective way to debug.
The first time in the blog Park article, so excited ~
Finally, I hope to help a lot of. NET programs like I don't know Linux but want to try. NET Core Ape, we all learn progress together!
"Starting out" start with a virtual machine and step-up on the CentOS run. Net Core Program