I have a .NET Core console app and have run dotnet publish
. However, I can\'t figure out how to run the application from the command line. Any hints?
You can very easily create an EXE (for Windows) without using any cryptic build commands. You can do it right in Visual Studio.
With dotnetcore3.0 you can package entire solution into a single-file executable using PublishSingleFile
property
-p:PublishSingleFile=True
Source Single-file executables
An example of Self Contained
, Release
OSX executable:
dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=True --self-contained True
An example of Self Contained
, Debug
Linux 64bit executable:
dotnet publish -c Debug -r linux-x64 -p:PublishSingleFile=True --self-contained True
Linux build is independed of distribution and I have found them working on Ubuntu 18.10, CentOS 7.7, and Amazon Linux 2.
A Self Contained executable includes Dotnet Runtime and Runtime does not require to be installed on a target machine. The published executables are saved under:
<ProjectDir>/bin/<Release or Debug>/netcoreapp3.0/<target-os>/publish/
on Linux, OSX and
<ProjectDir>\bin\<Release or Debug>\netcoreapp3.0\<target-os>\publish\
on Windows.
Go to ...\bin\Debug\net5.0
(net5.0 can also be something like "netcoreapp2.2" depending on the framework you use.)
Open the power shell by clicking on it like shown in the picture.
Type in powershell: .\yourApp.exe
You don't need dotnet publish just make sure you build it before to include all changes.
before you run in cmd prompt, make sure "appsettings.json" has same values as "appsettings.Development.json".
In command prompt, go all the way to bin/debug/netcoreapp2.0 folder. then run "dotnet applicationname.dll"
If it's a framework-dependent application (the default), you run it by dotnet yourapp.dll
.
If it's a self-contained application, you run it using yourapp.exe
on Windows and ./yourapp
on Unix.
For more information about the differences between the two app types, see the .NET Core Application Deployment article on .Net Docs.
Using CMD you can run a console .net core project if .net core SDK is installed in your machine :
To run console project using windows command-Line, choose the specific path from your directory and type following below command
dotnet run