How to run .Net Core dll?

I am creating a console application using the dnu build on my Mac. The output of MyApp.dll .

How is it not MyApp.exe , how can I execute it in windows or even on Mac?

The code:

 using System; class Program { public static void Main() { Console.WriteLine("Hello from Mac"); } } 
+25
c # .net-core
source share
2 answers

Add this to your project.json file:

  "compilationOptions": { "emitEntryPoint": true }, 

It will create MyApp.exe on Windows (in bin / Debug) or executable files on other platforms.

Change: 01/30/2017

It is not big enough. You now have the opportunity between Framework-dependent deployment and standalone deployment, as described here .

Short form:

Platform Dependent Deployment (.net Core Present on Target System)

  • Launch dll using the dotnet command line utility dotnet MyApp.dll

Offline deployment (all components, including the .net kernel runtime, are included in the application)

  • Remove "type": "platform" from project.json
  • Add runtime section to project.json
  • Assembly with the target operating system dotnet build -r win7-x64
  • Run the generated MyApp.exe

project.json file:

 { "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true }, "frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.1" } } } }, "imports": "dnxcore50", "runtimes": { "win7-x64": {} } } 
+25
source share

You can use dotnet publish to generate .exe output for your console application.

Learn more: Publish .NET Core applications using the command line interface.

+4
source share

All Articles