1

I need to run a self contained .net core application in mac. I been able to do this in Linux and in Windows. I am only missing to run this application in mac. Maybe I am doing something wrong. This is what I am doing:

1) Create a hello world application target .Net Core 2.1

using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

2) Publish that application for Mac osx.10.12-x64. On command prompt I run the following command:

dotnet publish "C:\Users\Foooooo\ConsoleApp4.csproj" --self-contained --runtime osx.10.12-x64

3) I then place that output in the mac and switch to root user in terminal with:

sudo -i

4) I then try to execute my application as ./ConsoleApp4 But I get an error message saying permission denied.

enter image description here


P.S.

I know I can install dotnet core on the mac and then run my executable as dotnet ./ConsoleApp4. I do not want to install dotnet core on the mac I want to take advantage of the --self-contained feature. This works great when publishing into windows (--runtime win7-x64) and linux (--runtime linux-x64). I am just missing to run this app on mac. Why do I get the permission denied error if I am root on the terminal?


Solution

Sorry I am not a mac/linux guy I forgot to execute chmod +x on the file. When I googled for permissions if found the command sudo -i. Thanks @chue for the solution on your comments.

Tono Nam
  • 34,064
  • 78
  • 298
  • 470
  • It seems strange that your binary ends in "dll" and not "exe". Perhaps there's something in the csproj that we don't know about? – chue x Jun 27 '19 at 02:30
  • When you publish for windows `--runtime win7-x64` you get a .exe file. But when you publish for mac or linux the output file does not contain an exe. I know this because I already tried it on linux and it worked when I ran the command `./ConsoleApp4` on ubuntu. – Tono Nam Jun 27 '19 at 02:35
  • 1
    Just taking a guess, but does the application have execute permisions? `chmod 777 ConsoleApp4` – chue x Jun 27 '19 at 03:05
  • 2
    Or `chmod u+x ConsoleApp4` – chue x Jun 27 '19 at 03:07

0 Answers0