0

I have a small c# winform app developed under .net framework 4.5. Now I need find a way to convert it to Mac Os app. I don't want to use Crossover or Mono. In fact, I need to find a way to make an installer for Mac OS.

I have VS2017 on pc and VS for Mac and XCode on mac

I thought I had once seen an option in Visual Studio (like export to XCODE or something like that) that would create an XCode project and put it in a folder called __MACOSX.

Can anyone outline the correct tools or steps to port my WinForms app to MacOS and create an installer for it?

mdisibio
  • 3,148
  • 31
  • 47
roozbeh S
  • 1,084
  • 1
  • 9
  • 16

1 Answers1

1

You're targetting .net framework 4.5, that framework only runs on windows, It's not possible to deploy your application to mac unless you install windows on it. If you want your windows forms application to work on mac you could target a different framework (I know you don't want to do that, but it's the only way). You could target .NET Core 3.0 although it's still in preview version, the official version of it will be released on september this year, and it'll supports winforms.

You could try to target the last preview version and try yo recompile everything in order to make an executable that works on Mac.

In order to target the .NET Core Framework First you'd have to download the latest preview version of .NET Core SDK 3.0 and install it. Then check that it has been installed correctly by running a dotnet --info command in the console it should show you something like:

.NET Core SDKs installed:

3.0.100-preview4-011223 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:

Microsoft.AspNetCore.App 3.0.0-preview4-19216-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Microsoft.NETCore.App 3.0.0-preview4-27615-11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Microsoft.WindowsDesktop.App 3.0.0-preview4-27613-28 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

You'd also have to have the latest preview Version of Visual Studio 2019

Then you should enable the preview development with Visual Studio, to do it you should go to Tools → Options → Projects and Solutions → .NET Core and check Use preview versions of the .NET Core SDK Though I believe that in VS2019 preview version it's enabled by default

The project structures between the windows forms projects targetting .Net Core and .Net Framework are actually pretty different so it'd be better to start a new Solution from scratch. Using the templates of Visual Studio 2019 Create a new Windows Form Project targetting .NET Core. Then you'd have to grab all the files from the old project targetting .NET Framework to the new one, if you have many projects you'd have repeat the process but adding a new project to the same solution, and then to wire up the references between those projects in order to compile. If you have class library projects the best choice would be to target them to .net standard class libraries instead of .net core class libraries.

If you're using Nuget packages make sure that you download the .NET Core versions of them.

Note: Since winforms in .NET Core is still a preview version maybe not all of the features you've used in your previous project work. (Also note that you're using an entirely new framework so some things could have changed or some others could be missing in .NET Core).

carlos chourio
  • 853
  • 7
  • 16