Visual Studio for Mac Preview

Source: Internet
Author: User


Microsoft Visual Studio for Mac Preview download + install + Case Demo

Directory:

0. Preface

1. Online Installer

2. Install vs

3. HelloWorld

4. ASP. NET MVC

5. Software download

6. End







0. Preface:


Work reasons, commute my thunder god, one months thin 10 pounds, can't carry, put my Mac in the company.



Mac before in order to run VS, also bought a PD virtual machine ...






Now, I finally got the chicken soup-with the release of Visual Studio 2017, the for Mac version was born,






We can go to VisualStudio official website to download, but may be a bit slow, I uploaded Baidu Cloud. The article concludes with a download.



MAC installation has always been simple, loading images, dragged into the app can be, here to take care of the novice, simply say the process:






PS: Also enough, write this article, the browser has collapsed n times. How many times have you rewritten. =_= "





1. Online Installer


Download get visualstudioformacpreviewinstaller.dmg, size 23.9MB, this is the installation program, plainly is installed online.



(download at the end of the article)



Double-click image loading:









Double-click the download icon to bring up an interface that you understand:









After accepting and continuing, you are prompted to check the network link:









Sao wait 10 seconds or so, will prompt the network link error:









Anyway, I have been stuck in this mistake, as if to feel the whole life is fixed here.



But fortunately, before the installation of VS2015 ANDROIDSDK, also appeared this error, so I subconsciously looked down to find. A highlight was found:









This is not the visual Studio for Mac installation program?!



Decisive right-copy link, paste into the thunderbolt ... Ah haha.



Then you get the installer, which is 216.3MB. (download at the end of the article)








2. Install vs Program


After the Thunderbolt download is complete, double-click the photographed image:









This will know how to get it ~ haha. Drag directly into the applications and the installation is complete. Oh.









Chicken jelly, medicine can not stop, continue to engage!








3. HelloWorld


Click on the Visual Studio launch icon to start VS, and you'll see the VS Main program:









Personally think better than Xcode, may be because the bottom left corner of the icon, hehe.



Click New Project ... Start a new project.






First of all, about the project template, probably divided into multiplatform, literally translation should be cross-platform project it:









Then, the project for. NET Core:









And finally the other thing:









You can also change the programming language by clicking the following language drop-down box:









No nonsense, choose Console Project (C #)-Next:









After entering the project name, solution name, and path, click Create:









The classic interface, tools on the left, online documentation and unit tests, the right side is the solution, the following are errors and so on.



such as code, click to run, automatically open the terminal, display the results:









It's kind of interesting to write a classic 99 multiplication table.



This code smart tip is still pretty bull X's:









Come, take a ~











4. Test ADO


Look at the project structure in the right-hand solution, which is almost the same as Windows vs.



For AssemblyInfo.cs assembly information such as:









We see that there is only one system reference in the console console project.



Let's practice the ADO, so we need to add System.Data references.



Right-click References (Reference)-Edit References ... (Edit reference):









The above is divided into all, Packages, Projects,. NET Assembly.



Where project refers to projects in the current solution,. NET assembly can select third-party components.






Here, we find System.Data and System.Configuration:









After you add a reference, you will find that there are two more references in the project reference:









Below, we add an application configuration file (App. config).



Right-click Project-ADD File:









Select Misc-application Configuration File and click OK:









Add the Classic link string code in app. Config, this comparison pit, no hint. You can only knock with your memory.



The code is as follows:









Write the ADO Code test ADO component in the main () method.



Because I am linked to the server, the database I can not remember what is. So the direct connection is the master database, select the name of sysobjects:


ADO. NET Test Code








The results of the operation are as follows:









Ha ha. Kind of mean, my brother.








5. Test ASP. NET MVC


Keep the strike.



Right-click the solution and add the project:









Select Other-asp.net MVC Project and click Next Next:









Then configure the project, choose whether to create WEBAPI and unit tests, and then next:









Then configure the project name, path, and so on, then click Create:









After the creation is finished, I thought it was done, but a hint pops up:









In other words, the project needs the following items, you need to click to accept the installation, in order to complete the matter.



Do not recruit, point Bai, or MVC related things, such as controller and so can not be used.






Click on Accept, shown above adding Packages ... (Adding components):









Wait 10 seconds or so, hint packages successfully added. (Add complete):









Probably look at the project structure on the right, the same as our usual project structure.



Controllers is the controller, views is the view, models is the model, scripts is the script, ... It's needless to say.



So, the start is quite fast, hehe.






Click Run directly to see the effect:









Oh, a little meaning.






To add the user model class in models:


1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Web;
  5 using System.Web.Mvc;
  6 using System.Web.Mvc.Ajax;
  7
  8 namespace HelloWorldMVC.Controllers
  9 {
10 public class HomeController: Controller
11 {
12 public ActionResult Index ()
13 {
14 var users = new []
15 {
16 new User () {Id = 1001, Name = "Zhang Dong", Email = "[email protected]"},
17 new User () {Id = 1002, Name = "Caterina", Email = "[email protected]"},
18 new User () {Id = 1003, Name = "blind monk", Email = "[email protected]"},
19 new User () {Id = 1004, Name = "Moganna", Email = "[email protected]"},
20 new User () {Id = 1005, Name = "Bounty", Email = "[email protected]"}
twenty one             };
twenty two 
23 ViewBag.Users = users;
twenty four 
25 return View ();
26}
27}
28}
 





Modify the Controllers/homecontroller.cs controller code, create the user array, and deposit into the ViewBag:


1 @if (ViewBag.Users == null)
  2 {
  3 <p> No information. </ p>
  4}
  5 else
  6 {
  7 <table>
  8 <thead>
  9 <tr>
10 <th> Numbering </ th>
11 <th> Name </ th>
12 <th> Mailbox </ th>
13 </ tr>
14 </ thead>
15 <tbody>
16 @foreach (var item in ViewBag.Users)
17 {
18 <tr>
19 <td> @ item.Id </ td>
20 <td> @ item.Name </ td>
21 <td> @ item.Email </ td>
22 </ tr>
twenty three             }
24 </ tbody>
25 </ table>
26}








Modify the Views/home/index.cshtml code to display the array information just deposited:


 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8">
 5     <title>@ViewBag.Title</title>
 6 </head>
 7 <body>
 8     @RenderBody()
 9 </body>
10 </html>





Click to run:









Ah yo i xxxx. Open views/shared/layout.cshtml, sure enough, set the encoding format and add meta changes as follows:











Run again:

















OK, the end of the thing ~















5. Software download


Online installation +vs installer package download





















6. End


Haha, to this, the case has been tested, the feeling is good.





Just a little, seemingly self-bringing no form application ...





Visual Studio for Mac Preview

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.