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

前端 未结 7 864
-上瘾入骨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:31

    You can also run your app like any other console applications but only after the publish.

    Let's suppose you have the simple console app named MyTestConsoleApp. Open the package manager console and run the following command:

    dotnet publish -c Debug -r win10-x64 
    

    -c flag mean that you want to use the debug configuration (in other case you should use Release value) - r flag mean that your application will be runned on Windows platform with x64 architecture.

    When the publish procedure will be finished your will see the *.exe file located in your bin/Debug/publish directory.

    Now you can call it via command line tools. So open the CMD window (or terminal) move to the directory where your *.exe file is located and write the next command:

    >> MyTestConsoleApp.exe argument-list
    

    For example:

    >> MyTestConsoleApp.exe --input some_text -r true
    
    0 讨论(0)
提交回复
热议问题