Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sample analysis of Visual Studio for Mac version

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shares with you the content of the sample analysis for the Visual Studio for Mac version. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Your favorite IDE is now available for Mac. Because before Visual Studio for Mac, there was Visual Studio Code for Mac, and at that time we thought that Visual Studio Code was the cross-platform version of Visual Studio, but in fact Microsoft did not think so. Visual Studio Code is still too simple compared to Visual Studio, and the enterprise application development Visual Studio Code is still somewhat inadequate, so Visual Studio for Mac was born, and it is uncertain that there will be Visual Studio for Linux and so on.

Net development in the Mac computer, my own situation is to install VMware Fusion, and then install Windows 10 Magi Windows 10 in the virtual machine with Visual Studio 2017. Of course, Windows 10 only contains .NET software development programs. If you want to install Wechat or QQ in Windows 10, it is recommended that you directly change the Mac system to Windows 10. My principle is that Windows 10 only writes code and other things are done on Mac, but even so, as long as the virtual machine is turned on. Then turn on two more Visual Studio 2017 Magi Mac cooling fans and keep buzzing, even if the virtual machine memory is divided into four cores of 8G Magi CPU, it won't help.

Of course, if the .NET development program is relatively simple, or pure code-based projects, there is no need to install a virtual machine, just use Visual Studio Code for Mac or other editors.

Of course, if Mac can fully develop .NET, it will be perfect, so hurry up and install Visual Studio for Mac, la ~

The installation steps are as follows:

Note: if the above "unable to connect to the network" error occurs, the network needs to cross the wall.

Note: above, you need to select the content to be installed below. If you install it all, you need 4.31g. If you don't choose mobile development, just choose .NET Core and only 897MB (I chose this one).

Note: after I choose the installation content, click "install" and suddenly get stuck, and then quit the program to reinstall, there is the above error, I thought that the installation can not be installed, the last time to install, and suddenly can, very strange, if you encounter some mistakes, just install a few more times.

Note: if the above error occurs in the installation, click "retry", and if it still doesn't work, click again.

After installation, we use the actual project IdentityServer4.Demo to test whether Visual Studio for Mac is available? How is the experience? Can enterprise-level development be carried out?

First of all, open the IdentityServer4.Demo.sln solution with Visual Studio for Mac and find that it cannot be opened. Report the following error:

Error message: a project file of type .xproj was not found.

Then go to the project folder to find the project file of type .xproj, but only the project file of type .csproj:

Then use notepad to open the IdentityServer4.Demo.sln solution:

The copy code is as follows:

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

IdentityServer4.Demo.sln solution files are full of files of type .xproj.

IdentityServer4.Demo.sln solutions can be opened with Visual Studio 2017, but why can't Visual Studio for Mac be opened? What's the reason? Also, why is the file type in the IdentityServer4.Demo.sln solution inconsistent with the actual file type?

The reason starts with the creation of the IdentityServer4.Demo project. IdentityServer4.Demo created the .NET Core project with Visual Studio 2015. At that time, the project package management used project.json files, and the project files were .xproj. Later, I installed Visual Studio 2017, and then the project was automatically upgraded, project.json/.xproj became .csproj, and Microsoft changed all project file extensions to .csproj (for details: .NET Core plans to discard project.json). But instead of changing .xproj to .csproj in the solution file, it just made Visual Studio 2017 compatible (why not replace it all? It's a bit of a pit.

What if Visual Studio for Mac can't handle compatibility like Visual Studio 2017 does? We can only manually change .xproj to .csproj in the IdentityServer4.Demo.sln solution file.

Use Visual Studio for Mac to open the IdentityServer4.Demo.sln solution again, and after a period of nuget restore, it will be fine:

There is an "exclamation point" next to each item (screenshot is not available), prompting messages:

Project not built in active configuration

The reason is that the latest version of .NET Core SDK is not installed, just reinstall the latest version.

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

Suddenly found that there was Visual Studio for Mac a long time ago, but at that time it was called Visual Studio MacOS, and it was a beta version. I thought Visual Studio for Mac was available today. It seems that it is really ill-informed.

Recompile the entire solution and find errors (IdentityServer4.Demo was successful, but I tried other projects that failed, and for demonstration purposes, I manually added the code):

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 Content 5): Error: contains duplicate "Content" entries. The .NET SDK includes the "Content" item in your project by default. You can delete these items from the project file, or if you want to include their display in the project file, you can set the EnableDefaultContentItems property to false. Duplicates are: 'Properties/launchSettings.json' (ImplicitServer.Web.Tests)

As you can see from the above, the reason for the error is that .NET SDK contains the Content entry by default, so we can remove the Content inclusion entry in the .csproj file as follows:

Recompile the solution, Build Successful:

Then right-click the project and select "Run Item", or select "Run-Restart Without Debugging" in the menu bar to start the project.

Debugging the project is also very simple. Select "Run-Restart Debugging" in the menu bar, and you can set a breakpoint to debug:

In addition, it is comfortable to write code in Visual Studio for Mac, which is not very different from Visual Studio 2017. Smart tips are perfect, and even some keyboard shortcuts are supported, such as pressing Tab after typing if to expand the code.

Visual Studio for Mac Settings Nuget Source:

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

Visual Studio for Mac also has some bad experiences, such as:

Some icons are too small to see clearly (such as git project or file change icons, there are some screenshots above, but it is difficult to find, there are some tool icons, etc.) some buttons and Tab switch experience is very poor, very stiff feeling, but can be used to optimize later. Compatibility is not good, such as the error mentioned above, there is no problem with the use of the IdentityServer4.Demo project, but I have tried some actual work projects, there are still some problems with opening and using. The unit test project cannot be opened (xUnit), as shown below.

Maybe that's it, and there may be some problems that haven't been found, but I think Visual Studio for Mac can really be used for development (enterprise development, not for fun). After all, it's cool to develop .NET Core under Mac, but Microsoft mainly does mobile development on this version of Visual Studio for Mac (as can be seen in promotional articles and installation options). There may be some problems in the development of .NET Core services. But it will certainly be improved in the future, and we can use it first. It's just a problem of stepping on the pit.

Thank you for reading! This is the end of this article on "sample Analysis of the Visual Studio for Mac version". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report