How to run .NET Core console app from the command line

前端 未结 7 889
-上瘾入骨i
-上瘾入骨i 2020-12-07 09:30

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?

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 10:10

    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:

    /bin//netcoreapp3.0//publish/ on Linux, OSX and

    \bin\\netcoreapp3.0\\publish\ on Windows.

提交回复
热议问题