The day has arrived when you can both develop and deploy services for .NET Development on Mac. For that, you’re going to need either a souped-up text editor (such as Sublime Text, Brackets, Atom, Emacs or Vim) together with OmniSharp for IntelliSense, or you’ll want to use Visual Studio Code, the new cross-platform IDE from Microsoft that uses OmniSharp with Roslyn and provides Git integration for version control, plus limited debugging support.
Setting up an environment for .NET development on MacIn the past when doing .NET development, I’ve typically relied on running a Windows virtual machine inside VMware Fusion. This is still a good option, but nowadays it is possible to develop .NET applications on Mac OS without the use of a virtual machine. In today’s short post we’ll go over the setup required to do so.
What will our development environment consist of?The typical .NET setup makes use of .NET (duh), SQL Server, and some sort of IDE. Today we’ll be installing the following:
- SQL Server (inside Docker).
- The .NET Core SDK.
- Visual Studio Code.
Installing SQL ServerIn order to run SQL Server on a Mac, we’ll need to run it from within Docker. So our first step will be to install Docker.
Installing DockerThe Docker installation is straightforward, just download and install the Mac version of the Docker Desktop. (Note: you’ll need to sign up for a Docker account in order to download the installer.) Once you’ve downloaded and installed Docker Desktop, launch Docker and you’ll see it running in your menu bar. With Docker installed we can now move onto installing SQL Server.
Installing SQL Server inside DockerWe have a number of terminal commands available now that Docker is installed; one of which is search. We can use this to search for the image we need and can download the image with the pull command.
Installing .NET CoreInstalling .NET Core is a snap, just download and run the SDK installer. After doing so, you should be able to run the dotnet command from a terminal window.
Installing Visual Studio CodeThe editor of choice these days is Atom, but Visual Studio Code seems to be very popular and when it comes to developing .NET applications it stands to reason that a Microsoft product is likely to provide the best experience. Installation is straightforward, just download the installer and start.
Configuring Visual Studio CodeThere are a few configuration/setup steps that were helpful when setting up Visual Studio Code. Add the executable to PATH. This allows you to open VSC via the terminal which can be useful for opening a specific directory or the current directory.
The parameters are pretty self-explanatory; the only thing you might want to change is the name or the password value (you need to use a password that meets the SQL Server password policy). Once the above command has run we can verify that SQL Server is running via docker ps -a.
To get this working, open the command palette (View -> Command Palette, or Cmd-Shift-P) and type the shell. You’ll see an option to “Install ‘code’ command in Path”.
Getting integrated terminal working. VSC has an integrated terminal window but if initially, that doesn’t work and an error message flashes up in the terminal window that would crash, and then you may get the following dialog.
The terminal process command ‘/bin/bash –I’ failed to launch (exit code: 1)For some reason during when the terminal window was opening it was attempting to cd into a directory that did not exist. Then a simple solution:
Go to user settings (Code -> Preferences -> Settings) and then search for terminal.integrate:cwd.
One of the first items you’ll see is the start path value, edit it to a directory that actually exists and all will be well. That’s it for setting up a .NET development environment on a Mac, pretty simple!
Tools for .NET Development on Mac
Keyboard RemappingOne of the most frustrating moments when switching to Mac from Windows could be the keyboard layout. The layout of the Control key, Option key, and Command key is completely different, so remap those keys to continue the Windows development experience by the following app.
Better Snap ToolMac OS provides the screen split view feature, but it's fairly basic. If you want more, you need to look for a third-party tool. Better Snap Tool is precisely for this purpose. It doesn't only provide a screen split view from many different perspectives but also provides shortcut features for each split view.
.NET Core SDK.NET Core has now been older than three years as a cross-platform and open-source language and framework. The latest version of the .NET Core SDK is 3.1.10. You can download it from the official website.
PowerShell CorePowerShell used to be a scripting language, only running on Windows. It's now open-source and supports cross-platform. Therefore, you can continue the existing PowerShell scripting experience on Mac. Use the Homebrew command to install PowerShell on your Mac.
Azure CLILike Azure PowerShell, Azuer CLI is a cross-platform tool that manages Azure products and services. While developing applications running on Azure, both Azure PowerShell and Azuer CLI are necessary because they complement each other. Therefore installing both would be a good idea.
AzuriteAzurite is an emulator for Azure Storage, and an npm package that running on multiple platforms. If we develop an Azure Functions app, we mostly need Azure Storage account. On Windows, we can use Azure Storage Emulator for local development, but we can't use it on the other platform. Therefore, Azurite is really a useful tool running cross-platform. The latest version is 3.3.0-preview, but it's not stable yet. So, using 2.7.1 would be great instead.
Azure Storage ExplorerAzure Storage Explorer helps navigate both local and cloud storage services like Azure Storage Account, Cosmos DB, and Azure Data Lake. It's also running on multiple platforms.
Docker for MacDocker for Mac runs dockerized containers natively on Mac OS. Docker includes Docker Engine, Docker CLI client, Docker Compose, Notary, Kubernetes, and Credential Helper.
GitKrakenMac OS contains the git CLI out-of-the-box. But, if you prefer to use GUI, there are many cross-platform tools for it. GitKraken is one of them. It offers both free and paid versions. In most cases, the free version would be sufficient.
IDEThere are roughly two IDEs on Mac for .NET application development. One is Visual Studio for Mac, and the other is Visual Studio Code.
- Visual Studio for Mac
- Visual Studio Code
PostmanPostman is still widely used for API development and testing. There are other useful tools as its alternatives. So, feel free to choose the right one for your purpose.
Snag ItSnag helps for screenshots. If you think that the default feature on Mac OS is not enough, this will be useful. But make sure that this requires payment. If you are seeking a free version, you better find out alternatives.
CamtasiaCamtasia helps with screen recording. Mac OS default feature is still OK, but if you need more features, then consider this tool.
GrammarlyGrammarly is particularly useful for developers who speak English as their second language. It picks up grammatical errors or suggests appropriate words by analyzing sentences and contexts. If you are writing some technical documents, Grammarly really will be your best friend.
Karabiner-Elements are a completely free app. It is really excellent for key remapping. After this remapping, both the left command key and the fn key combination get pretty similar to the one in Windows. Therefore, the Command + C and Command + V sequences will become really natural.
Visual Studio is a full-featured development platform by Microsoft that allows you to create, modify, and ship code from start to finish. Microsoft suggests multiple payment plans for the IDE to allow individual engineers and enterprises to leverage its rich toolset
Alternatively, we can use Visual Studio Code. It's built for cross-platform and has a large extensions pool. Admittedly it can't fully replace Visual Studio, but with many extensions, it can keep up most things. In fact, VS Code itself is enough for .NET applications. But installing several extensions will give you much relief.
This supports most modern web browsers, including Microsoft Edge, Mozilla Firefox, and Google Chrome, by providing browser extensions. Alternatively, you can download and install the desktop application.
In The EndSo far, we've discussed the setting upon the environment for .Net development on mac and several tools for running on Mac that may help or improve your experiences. I hope this article will help others in the future. If you have any software development needs on .Net based technologies, just drop an email to email@example.com.
What OdiTek offers
Refer our Skills page:
We had a tough deadline to launch our .Net based application that processes a lot of data, and got very frustrated with our development agency we hired. Fortunately we got Oditek, and they took over seamlessly the product development, launched the app & continued feature development. Just awesome!
They were very attentive to our needs as clients and went out of the way to make sure our projects were taken care of. They were always able to get projects done in the specifications we requested. They are passionate about getting things done; I would definitely recommend them to lead any IT projects.
I worked with OdiTek on few high profile banking application projects. They did a fantastic job with web applications & manual testing on the VAS apps for two leading banks of UK that included rigorous UAT phases. I recommend them for any application development where security matters.
OdiTek is our extended team who works on our key software projects. They are dependable, good in collaboration and technically very much to the level what we expect a global team should be. They had transformed our web applications, CRM and added mobility to existing business platforms here.
It's been more than 4 years now that we are working with OdiTek on our cloud based web product development. It's been amazing working together, they are very competent on designing scalable, high performance apps. Their technical support is outstanding to say the least, even at odd hours.
I am a fan of Team OdiTek since 2014 and have worked on many product development projects together. Specially worth mentioning their deliveries on VAS Banking web application development & manual testing services for Smarta, UK. They are highly skilled & a professional team to work with.
OdiTek has been working on our Integrated Web-scale Mobile Platform i.e. Optimal Health since 2014. They are very professional and takes care of the requirements meticulously. They are technically very sound and sincere in ensuring quality & performance. Wonderful working with them!
You can trust the team, with minimum supervision you get the work done. They are honest, professional & committed to schedule & quality. I had been successfully running 3 business applications designed, developed and maintained by Oditek developers. It’s been a pleasure working with them.
OdiTek has been working in custom software development, including services for test automation. Many of them have worked with me in 2009-10 when I was R&D Manager in NetHawk India. They have great enthusiasm & a passion to excel in bringing customer success. Their work has been very impressive.
It's amazing to see these guys are turning their experience into a global delivery excellence at OdiTek. I am sure their past large scale product development experience will be handy to product companies. I would always recommend Oditek for software development, especially performance-driven solutions.