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.
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.