.net For Mac



Xamarin is a set of tools and libraries for building cross-platform apps on the.NET platform. Build native apps for macOS, iOS, Android, and Windows on a shared.NET codebase. Share an average of 75% of app code across all platforms. Get started with Xamarin for macOS. Download.NET Core Runtime for Mac - Run and test.NET Core apps with the help of this open source and cross-platform deevlopment component that also performs actions like garbage collection and compilation to machine code. But I don't want to shut out users on the Mac or on Linux. OK, they can run Web applications, or use.Net Web Services, but that's not enough. I want to deliver those users my.Net executable and have them be able to run it. It runs:.Net on the Mac. Well, there's Mono. It looks good and I hope it succeeds. .NET 5.0 is the first release in our.NET unification journey. We built.NET 5.0 to enable a much larger group of developers to migrate their.NET Framework code and apps to.NET 5.0. We’ve also done much of the early work in 5.0 so that Xamarin developers can use the unified.NET platform when we release.NET 6.0. Note that while everyone mentions Mono and Xamarin, which you should absolutely look into for C# development, Unity works on Mac directly, specifically Mac OSX 10.6+ while both use the C# language, some of the paradigms espoused by Unity are a little different from standard C# development. I personally recommend learning both.

Mac

Disclaimer: I am not on the .NET Core Team. I used the tools available publicly and have no insights into the future of .NET Core. It looks very bright though. :)

The working source code for this project can be found here.

Intro

A complete list of post in this series is included below :

Visual Studio.net For Mac

In this post, we’re going to look at running the app from the command line and then the Mac.

Running the App in the Windows Command Prompt

While you can obviously run the app inside of Visual Studio with the F5 command. You should also know that you can run the app inside of the console. Before we begin, make sure you have the app found here. After opening the app or downloading it, open the folder containing the project in the command prompt.

You can run your application here by simply typing :

.net for mac os

You will the following output :

The exact same result from running the console app in Visual Studio.

Using dotnet publish to get the app ready for Mac

Go ahead and type dotnet publish on the command prompt and then type tree to look at your directory listing as shown below :

.netMac

You should see the publish directory. Navigate into it and list out the files in the directory :

.net For Mac

Take note that the dlls listed below are related to the package reference that we added in the last blog post.

  • Newtonsoft.Json.dll
  • System.Runtime.Serialization.Primitives.dll
.net For Mac

This only leaves the NetCoreConsoleApp.dll which is the Console application that we can run on a Mac (or any other platform that supports .NET Core).

Running the app on a Mac

Finally! It is about time you might say. I agree. Before you can run the app on your Mac, you’re going to need to head back over to the .NET Core downloads page and install OpenSSL and then the SDK (or runtime) if you remember the difference from the first post.

To run this on your Mac, you’ll need to copy the ‘publish’ folder to your Mac. Then open Terminal and you can run the app by just typing :

This is awesome! Now you have an app that run on another platform and you used your existing .NET skillset to create it. I’m LOVING .NET Core!

Wrap-up

OK, I’m going to take a break and I’ll be back next week. As always, thanks for reading and smash one of those share buttons to give this post some love if you found it helpful. Also, feel free to leave a comment below or follow me on twitter for daily links and tips.