Visual Studio for MAC first experience

Source: Internet
Author: User
Tags vmware fusion


Not surprised? Not surprisingly? Surprise, but not surprisingly, because the Visual Studio code for Mac was already in place before Visual Studio for Mac, and we thought that Visual Studio Code was the cross-platform version of Visual Studio, but it Microsoft does not think so, Visual Studio code is too simplified relative to Visual Studio, enterprise-class application development Visual Studio Code is still a little too much, so the Visual Studio for Mac was born to Then there will be Visual Studio for Linux and so on.


For. NET development on MAC computers, my own situation is to install VMware Fusion, and then install Windows 10,windows 10 inside the virtual machine with Visual Studio 2017 installed, of course, Windows 10 is installed with. NET Software Development of the program, if you want to install in Windows 10 or QQ, then it is recommended that you directly change the MAC system to Windows 10, my principle is that Windows 10 write code, and other things on the MAC, but even so, as long as the virtual machine, and then open two Visu The Al Studio 2017,mac cooling fan has been "humming", even if the virtual machine memory 8g,cpu 4 cores.



Of course, if the. NET development program is simple, or a purely code-based project, there is no need to install a virtual machine, with Visual Studio code for MAC or other editors.



Of course, if the MAC can be fully developed in. NET, it's perfect, so hurry up and install Visual Studio for MAC, cheer up ~



The installation steps are as follows:




Note: If the "Unable to connect to network" error appears above, network wall is required.





Note: The above needs to select the next installation of content, all installed need 4.31G, if not select mobile development, only select. NET Core, only need 897MB (I choose this)





Note: After I choose to install the content, click "Install" Suddenly die, and then quit the program reinstall, there is the above error, I thought the installation can not, and finally installed once again, suddenly can, very strange, if you encounter some errors, install more than a few times good.






Note: If the installation appears above the error, click "Retry", if not, then click again.





After installation, we use the actual project Identityserver4.demo to test if Visual Studio for Mac is available? How does the experience work? Can I do enterprise-level development?



First, open the solution with Visual Studio for MacIdentityServer4.Demo.slnand find that it is not open to report the following error:





Error message:.xprojThe type of project file could not be found.



Then go to the project folder to find the.xprojtype of project file, not found, only.csprojthe type of project file:





Then open the solution with NotepadIdentityServer4.Demo.sln:


...
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{22BD0651-0313-496F-865B-9D6D94CB9407}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3FDA3CFF-E411-4166-A98C-42E1E5B252E3}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ClientCredentialsAndPassword.Web", "ClientCredentialsAndPassword.Web\ClientCredentialsAndPassword.Web.xproj", "{6BB34F8C-B0D7-4128-8DB9-9494591C0F94}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "APISource.Web", "APISource.Web\APISource.Web.xproj", "{F4980DEB-57D3-4C7F-ADBF-7A9F01ED94B8}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ClientCredentialsAndPassword.Web.Tests", "ClientCredentialsAndPassword.Web.Tests\ClientCredentialsAndPassword.Web.Tests.xproj", "{6BB31592-9DC2-4BE7-8E77-8ECED21040F4}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImplicitServer.Web", "ImplicitServer.Web\ImplicitServer.Web.xproj", "{118DE163-7D76-488F-BB99-F494101898D1}"
EndProject
...


IdentityServer4.Demo.slnThe solution files are all.xprojtypes of files.



IdentityServer4.Demo.slnThe solution can be opened with Visual Studio 2017, but why is the Visual Studio for Mac not open? What's the reason? And why is theIdentityServer4.Demo.slnfile type in the solution inconsistent with the actual file type?



The reason for this is that from the creation of the Identityserver4.demo project, Identityserver4.demo. NET Core Project created with Visual Studio 2015, when the project package manages the use of theproject.jsonfile and the project file is c1/>, then I installed Visual Studio 2017, and then the project was automatically upgraded under, andproject.json/.xproj.csprojMicrosoft changed all the project file extensions.csproj(see:. NET Core Program Deprecation Project.json), but did not change the solution file, but.xproj.csprojonly made Visual Studio 2017 compatible (why not replace it all?). A bit of a pit ~).



What if Visual Studio for MAC does not work as compatible with Visual Studio 2017? We can only manuallyIdentityServer4.Demo.slnchange the solution file.xproj.csproj.



Using Visual Studio for Mac to open theIdentityServer4.Demo.slnsolution again, after a period of timenuget restore, you can:





There is an exclamation point (not truncated) next to each item, prompting the message:


Project not built in active configuration


The reason is that you do not have the latest version of the. NET Core SDK installed, so you can reinstall the latest version.



Reference: Project not build in active configuration Visual Studio MacOS. NET Core



It suddenly dawned on me that I had Visual Studio for Mac earlier, but it was called Visual Studio MacOS, and it was beta, and I thought the Visual Studio for Mac was ignorant today.



Recompile the entire solution and find the error (Identityserver4.demo was successful, but I tried the other project failed, in order to demonstrate, the code I added manually):





Error Details:


/library/frameworks/mono.framework/versions/5.0.0/lib/mono/msbuild/15.0/bin/sdks/microsoft.net.sdk/build/ Microsoft.NET.Sdk.DefaultItems.targets (5,5): Error: Contains duplicate "content" items. The. NET SDK includes the "content" item in your project by default. You can remove these items from the project file, or you can set the Enabledefaultcontentitems property to False if you want the display to be included in the project file. The duplicates are: ' Properties/launchsettings.json ' (ImplicitServer.Web.Tests)


From the above you can see the cause of the error, the. NET SDK default containsContentitems, we can remove the.csprojinclusion items in the fileContent, remove the following:


<ItemGroup> <content include= "Properties\launchsettings.json"/></itemgroup>


Recompile the solution, build successful:





Then right-click on the project to select "Run item" or select "Run-restart without Debugging" on the menu bar to start the project.





Debugging the project is also very simple, the menu bar select "Run-restart debugging", you can set breakpoints debugging:





In addition, writing code in Visual Studio for Mac is very comfortable, and Visual Studio 2017 is not very different, smart tips are perfect, and even some shortcut keys are supported, such as typingifafter pressing theTabkey to expand the code.



Visual Studio for Mac sets Nuget Source:





From the current project directory, open the MAC terminal command:





Visual Studio for Mac also has a less-than-good experience, such as:


    • Some icons are too small to see (such asgititems or file change icons, some of them are, but hard to find, and some tool icons, etc.)

    • Some buttons and Tab switching experience is very poor, very blunt feeling, but can be used just fine, can be optimized behind.

    • Compatibility is not good, such as the above mentioned error, Identityserver4.demo project use no problem, but I tried some actual work items, open and use still some problems.

    • Unit test items cannot be opened (XUnit), such as.




That's about it, there may be some problems not found, but I think visual Studio for Mac can be really used for development (enterprise development, not to play), after all, under the Mac to do. NET Core development is pretty cool, but Microsoft in this version of the visual Stud Io for Mac, the main thing to do is mobile development (as can be seen in the promotion articles and installation options), the development of. NET Core Services may have some problems, but the following will certainly be perfected, we can use it first, just to step on the pit.






Visual Studio for MAC first experience


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.