macOS development manual


1. Preparing environment

In order to build multi-platform applications using .NET Core on macOS, the first steps are for installing in our MAC machine the required tools.

We need to install .NET Core SDK from Microsoft and to allow us to develop easier, we will install an advance editor with a lot of features, Visual Studio Code from Microsoft.

Both installations are very easy and the detailed description can be found by these two links:

  1. Install .NET Core SDK for macOS..
  2. Install VS Code for macOS..
  3. Install C# extension to facilitate us to code and debugging.

Important! The information is valid for versions up to 2024.X

At the time of this writing, .NET Core has a problem with supporting the GdiPlus library on macOS. There is a solution that will help you to run any .NET libraries using GdiPlus.

«System.Drawing .NET Core on macOS, GDIPlus Exception»

Problem:

You got the whole thing up and running in debug. But when you went for your dotnet run, you got the following crash:

Solution:

First of all, you need to install «Homebrew» - The missing package manager for macOS(or Linux).
Paste that in a macOSTerminal prompt:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The script explains what it will do and then pauses before it does it.

Homebrew installs the stuff you need that Apple (or your Linux system) didn't.
Paste that in a macOSTerminal prompt:
$ brew install wget
Homebrew installs packages to their own directory and then symlinks their files into /usr/local

Homebrew won't install files outside its prefix and you can place a Homebrew installation wherever you like.

Homebrew complements macOS(or your Linux system). Install your RubyGems with gem and their dependencies with brew.

Now, we need to install mono-libgdiplus. GdiPlus -compatible API on non-Windows operating systems.
Paste that in a macOSTerminal prompt:
$ brew install mono-libgdiplus

Congratulations, you have installed all the dependencies needed to run .Net components.

In next paragraphs we will explain in detail how to create simple console application. All of them are based on this VS Code guide:
Get Started with C# and Visual Studio Code
Not only is possible to create .NET Core applications that will run on macOS using Mac as a developing platform. It is also possible to create it using a Windows machine and any modern Visual Studio version, as Microsoft Visual Studio Community.

2. Preparing environment

<PackageReference Include="SautinSoft.PdfFocus" Version="*" />
<PackageReference Include="Svg.Skia" Version="1.0.0.3" />
<PackageReference Include="System.IO.Packaging" Version="4.4.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.3" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" /> 
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="6.0.4" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="SkiaSharp.NativeAssets.macOS" Version="2.88.6" />

3. How to launch a code sample

Create a simple project by Visual Code or an another Environment for C# or VB.NET. A lot of code samples on our web-site: www.sautinsoft.com or GitHub (SautinSoft).


If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below:



Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.