-1

Basically, my school only has Mac computers, however they're telling me to learn C# and to do so using Visual Studio. However, the school program is fairly new and the projects are self-guided. I've been coding in C# using Visual Studio and it's been working so far - it's run successfully and everything. However, I can't seem to find a way to export or publish my code into a standalone application. I've tried using WineBottler to convert the .exe into a .dmg, but I can't seem to make it work.

How should I do this? Moving to Windows or another IDE/compiler isn't an option. I've currently been creating my projects in a Console App, but I could change that if necessary.

KATTech
  • 63
  • 1
  • 9

3 Answers3

3

After quite a bit of experimentation and research, I've found that while you can publish a .NET Core Console App within Visual Studio for Mac, the feature is not supported within the GUI of the program (for whatever reason). In order to publish, you have to Control-Click on the solution in the Solution Explorer and open the project in the command line by clicking Tools > Open In Terminal. Once there, type in the command: dotnet publish -c Release --framework netcoreapp2.1 --runtime osx-x64 This will create a self-contained program for 64-bit mac os on the v2.1 .NET Core framework. The runtime can be changed for different operating systems and the version number for netcoreapp can be changed based on which version you're using and what is compatible with any plugins for your program. The final product will be found in yourprojectfolder/yourprojectname/bin/Release/netcoreapp2.1/osx-x64/publish

KATTech
  • 63
  • 1
  • 9
1

You should have no issues creating and compiling .NET CORE console apps using a Mac. These apps will have limited .NET functionality, do not have .exe files, and are platform agnostic. Here is a quick guide you can reference to decide if .NET CORE is the right option for you.

If you are trying to create WinForm apps or something similar, you cannot do this on a Mac. There are "work arounds" using Wine or other tools, but my experience with those options has been suboptimal at best. If you need to create apps like this, then your best option is to program on a Windows machine. Perhaps ask your school to enable bootcamp and install Windows 10 OS on one of the Mac machines.

Tom Hood
  • 497
  • 7
  • 16
  • Thank you for this answer. I've tried switching from the generic Console Application to the .NET CORE Console Application, and it's worked pretty well. However, I still can't seem to figure out how to publish the app as a standalone. Both the one I had been using and the one you suggested, I've had no problem compiling and running them through Visual Studio itself. I'm looking for a way to compile and build the code into a separate file that I can open outside of Visual Studio and move to other drives or other computers, regardless of whether they have Visual Studio or not. – KATTech Sep 17 '18 at 13:23
  • IIRC, .NET CORE creates .DLL files instead of .EXE or .DMG files, which is what allows it to remain platform agnostic. Try checking [this thread out](https://stackoverflow.com/questions/36516848/how-to-run-a-net-core-dll), as it appears to be handling a similar issue. Additionally, if my answers helped, please considering upvoting or marking as the correct answer :) – Tom Hood Sep 17 '18 at 15:42
0

You can generate exe using the terminal if you are on OSX. You can follow this post

It requires :

  • Visual Studio For Mac
  • A .cs file
  • Few lines in terminal
Motasim Foad
  • 87
  • 1
  • 1
  • 7