I've build my console application using dnu build
command on my Mac. The output is MyApp.dll
.
As it is not MyApp.exe
, how can I execute it on windows, or even on Mac?
The code is:
using System;
class Program
{
public static void Main()
{
Console.WriteLine("Hello from Mac");
}
}
Add this to your project.json file:
"compilationOptions": {
"emitEntryPoint": true
},
It will generate the MyApp.exe on Windows (in bin/Debug) or the executable files on other platforms.
Edit: 30/01/2017
It is not enough anymore. You now have the possibility between Framework-dependent deployment and Self-contained deployment as described here.
Short form:
Framework-dependent deployment (.net core is present on the target system)
dotnet MyApp.dll
Self-contained deployment (all components including .net core runtime are included in application)
"type": "platform"
from project.jsondotnet build -r win7-x64
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": {} }
}
You can use dotnet publish
to generate .exe output for your console app.
More details: Publish .NET Core apps with the CLI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With