Build .exe file in .NET Core RC2
There are actually 2 app models in .NET Core:
Portable apps: heavily inspired by "DNX console apps", these apps don't produce
.exe
files and are instead executed by the .NET Core shared runtime (whose version is defined by theMicrosoft.NETCore.App
package, thanks to its specialtype: platform
attribute). The corresponding .NET Core runtime must be installed on the machine to be able to use portable apps. If the exact version cannot be found, an exception is thrown when runningdotnet run
.Standalone apps: standalone apps are really similar to good old .NET console apps as they produce
.exe
files. The .NET Core runtime doesn't have to be installed on the machine, because it is directly embedded with the application itself.
You're currently using the first model. To use the standalone model, you need to tweak your project.json
:
- Add a
runtimes
section to list the environments your app will target (e.gwin7-x64
orubuntu.14.04-x64
). You can find the complete list here. - Remove the
Microsoft.NETCore.App
dependency. You can replace it by this package instead:"NETStandard.Library": "1.5.0-rc2-24027"
.
Here's an example of a standalone app:
{
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.Extensions.Configuration.Binder": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"NETStandard.Library": "1.5.0-rc2-24027"
},
"frameworks": {
"net451": { },
"netcoreapp1.0": {
"dependencies": {
"System.Net.Ping": "4.0.0-rc2-24027"
},
"imports": [
"dnxcore50",
"dotnet5.6",
"portable-net451+win8"
]
}
},
"runtimes": {
"win7-x64": { }
}
}
The answer is in the documentation with complete steps now.
You can create two types of deployments for .NET Core applications:
- Framework-dependent deployment
- Self-contained deployment
For a runnable .EXE file, the Publish self-contained should be used.