Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I execute a .net core console app on mac os

I just installed Visual studio for MAC, and created the hello world console app when pressing play in the bottom window (application output), I can see the hello world.

However , how do I execute that app from the command/terminal line?

If I try ./myapp.dll I get permission denied, even after sudo su.

so, not sure how to run it

this is my json

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.0"
        }
      }
    }
  },
  "runtimes": {
    "win10-x64": {},
    "osx.10.10-x64": {}
  }
}

Update

I have run dotnet restore, and dotnetrun, first I got this error: Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'osx.10.12-x64'. Possible causes:

Then I changed my project.json like this:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.0"
        }
      }
    }
  },
  "runtimes": {
    "win10-x64": {},
    "osx.10.12-x64": {}
  }
}

Then I get hundreds of errors like this: System.Threading.Tasks 4.0.11 provides a compile-time reference assembly for System.Threading.Tasks on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with osx.10.12-x64. System.Threading.Timer 4.0.1 provides a compile-time reference assembly for System.Threading.Timer on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with osx.10.12-x64.

Just listed a few J

I guess my runtime is incorrect for OSX, but should I set it?

like image 656
Luis Valencia Avatar asked Nov 16 '16 22:11

Luis Valencia


1 Answers

You need to run it with dotnet, like:

dotnet myapp.dll

To my knowledge, the tooling does not yet support Ready to Run (native) binaries, yet.

Then I get hundreds of errors like this: System.Threading.Tasks 4.0.11 provides a compile-time reference

Your project.json is missing the platform type for the framework. It should look like this:

"netcoreapp1.0": {
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    }
  }
}
like image 110
vcsjones Avatar answered Oct 14 '22 18:10

vcsjones