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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







125















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?










share|improve this question

























  • Perhaps this can be of help: stackoverflow.com/questions/44074121/…

    – Bent Tranberg
    Sep 6 '18 at 12:38


















125















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?










share|improve this question

























  • Perhaps this can be of help: stackoverflow.com/questions/44074121/…

    – Bent Tranberg
    Sep 6 '18 at 12:38














125












125








125


22






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?










share|improve this question
















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?







.net-core






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 20 '16 at 13:45









svick

177k40298417




177k40298417










asked Aug 25 '16 at 22:16









devlifedevlife

5,7581757111




5,7581757111













  • Perhaps this can be of help: stackoverflow.com/questions/44074121/…

    – Bent Tranberg
    Sep 6 '18 at 12:38



















  • Perhaps this can be of help: stackoverflow.com/questions/44074121/…

    – Bent Tranberg
    Sep 6 '18 at 12:38

















Perhaps this can be of help: stackoverflow.com/questions/44074121/…

– Bent Tranberg
Sep 6 '18 at 12:38





Perhaps this can be of help: stackoverflow.com/questions/44074121/…

– Bent Tranberg
Sep 6 '18 at 12:38












3 Answers
3






active

oldest

votes


















166














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.






share|improve this answer





















  • 8





    Its amazing how long it took me to find this out. I am trying all kinds of "dotnet run" commands, etc. This is the first place that I have come across in a lot of searching that gives the correct dotnet usage for running a console application. Why did Microsoft make .NET Core so un-developer friendly?

    – Glen Thomas
    Mar 21 '17 at 10:25






  • 2





    @GlenThomas If you want to run an application you're developing, you use dotnet run. Also, where did you look? Where would you expect this information?

    – svick
    Mar 21 '17 at 12:07











  • "dotnet run" no longer seems to be the case with .NET core projects using the newer MSBuild csproj setup rather than the old project.json files.

    – Glen Thomas
    Mar 21 '17 at 15:09








  • 1





    @GlenThomas That's not true, dotnet run works the same for the new csproj projects as it did for project.json.

    – svick
    Mar 21 '17 at 16:30






  • 4





    @GlenThomas, not sure if this is the problem you were having, but when you try to use dotnet run, make sure you're in the project directory, not the solution directory.

    – Ryan Lundy
    Dec 12 '18 at 9:52



















12














You can very easily create an EXE (for Windows) without using any cryptic build commands. You can do it right in Visual Studio.




  1. Right click the Console App Project and select Publish.

  2. A new page will open up (screen shot below)

  3. Hit Configure...

  4. Then change Deployment Mode to Self-contained or Framework dependent

  5. If you now view the bin folder in explorer, you will find the .exe file.

  6. You will have to deploy the exe along with any supporting config and dll files.


Console App Publish






share|improve this answer





















  • 2





    Yep. There's the EXE - along with 217 other files (api-ms-win-core-namedpipe-l1-1-0.dll, etc). Is there anyway to bundle this down to a single EXE?

    – Elton
    Jan 9 at 16:35






  • 1





    Good question @Elton. I don' know. AFAIK you have to deploy all the dlls.

    – Jess
    Jan 10 at 13:15






  • 1





    I would think the fact that it is configured to be self-contained would require all of those DLLs to be there. If you don't want them there, the deployment mode would probably need to be Framework Dependent

    – kippermand
    Feb 21 at 18:51



















9














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





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39155571%2fhow-to-run-net-core-console-app-from-the-command-line%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    166














    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.






    share|improve this answer





















    • 8





      Its amazing how long it took me to find this out. I am trying all kinds of "dotnet run" commands, etc. This is the first place that I have come across in a lot of searching that gives the correct dotnet usage for running a console application. Why did Microsoft make .NET Core so un-developer friendly?

      – Glen Thomas
      Mar 21 '17 at 10:25






    • 2





      @GlenThomas If you want to run an application you're developing, you use dotnet run. Also, where did you look? Where would you expect this information?

      – svick
      Mar 21 '17 at 12:07











    • "dotnet run" no longer seems to be the case with .NET core projects using the newer MSBuild csproj setup rather than the old project.json files.

      – Glen Thomas
      Mar 21 '17 at 15:09








    • 1





      @GlenThomas That's not true, dotnet run works the same for the new csproj projects as it did for project.json.

      – svick
      Mar 21 '17 at 16:30






    • 4





      @GlenThomas, not sure if this is the problem you were having, but when you try to use dotnet run, make sure you're in the project directory, not the solution directory.

      – Ryan Lundy
      Dec 12 '18 at 9:52
















    166














    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.






    share|improve this answer





















    • 8





      Its amazing how long it took me to find this out. I am trying all kinds of "dotnet run" commands, etc. This is the first place that I have come across in a lot of searching that gives the correct dotnet usage for running a console application. Why did Microsoft make .NET Core so un-developer friendly?

      – Glen Thomas
      Mar 21 '17 at 10:25






    • 2





      @GlenThomas If you want to run an application you're developing, you use dotnet run. Also, where did you look? Where would you expect this information?

      – svick
      Mar 21 '17 at 12:07











    • "dotnet run" no longer seems to be the case with .NET core projects using the newer MSBuild csproj setup rather than the old project.json files.

      – Glen Thomas
      Mar 21 '17 at 15:09








    • 1





      @GlenThomas That's not true, dotnet run works the same for the new csproj projects as it did for project.json.

      – svick
      Mar 21 '17 at 16:30






    • 4





      @GlenThomas, not sure if this is the problem you were having, but when you try to use dotnet run, make sure you're in the project directory, not the solution directory.

      – Ryan Lundy
      Dec 12 '18 at 9:52














    166












    166








    166







    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.






    share|improve this answer















    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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 17 '17 at 11:48

























    answered Aug 25 '16 at 22:41









    svicksvick

    177k40298417




    177k40298417








    • 8





      Its amazing how long it took me to find this out. I am trying all kinds of "dotnet run" commands, etc. This is the first place that I have come across in a lot of searching that gives the correct dotnet usage for running a console application. Why did Microsoft make .NET Core so un-developer friendly?

      – Glen Thomas
      Mar 21 '17 at 10:25






    • 2





      @GlenThomas If you want to run an application you're developing, you use dotnet run. Also, where did you look? Where would you expect this information?

      – svick
      Mar 21 '17 at 12:07











    • "dotnet run" no longer seems to be the case with .NET core projects using the newer MSBuild csproj setup rather than the old project.json files.

      – Glen Thomas
      Mar 21 '17 at 15:09








    • 1





      @GlenThomas That's not true, dotnet run works the same for the new csproj projects as it did for project.json.

      – svick
      Mar 21 '17 at 16:30






    • 4





      @GlenThomas, not sure if this is the problem you were having, but when you try to use dotnet run, make sure you're in the project directory, not the solution directory.

      – Ryan Lundy
      Dec 12 '18 at 9:52














    • 8





      Its amazing how long it took me to find this out. I am trying all kinds of "dotnet run" commands, etc. This is the first place that I have come across in a lot of searching that gives the correct dotnet usage for running a console application. Why did Microsoft make .NET Core so un-developer friendly?

      – Glen Thomas
      Mar 21 '17 at 10:25






    • 2





      @GlenThomas If you want to run an application you're developing, you use dotnet run. Also, where did you look? Where would you expect this information?

      – svick
      Mar 21 '17 at 12:07











    • "dotnet run" no longer seems to be the case with .NET core projects using the newer MSBuild csproj setup rather than the old project.json files.

      – Glen Thomas
      Mar 21 '17 at 15:09








    • 1





      @GlenThomas That's not true, dotnet run works the same for the new csproj projects as it did for project.json.

      – svick
      Mar 21 '17 at 16:30






    • 4





      @GlenThomas, not sure if this is the problem you were having, but when you try to use dotnet run, make sure you're in the project directory, not the solution directory.

      – Ryan Lundy
      Dec 12 '18 at 9:52








    8




    8





    Its amazing how long it took me to find this out. I am trying all kinds of "dotnet run" commands, etc. This is the first place that I have come across in a lot of searching that gives the correct dotnet usage for running a console application. Why did Microsoft make .NET Core so un-developer friendly?

    – Glen Thomas
    Mar 21 '17 at 10:25





    Its amazing how long it took me to find this out. I am trying all kinds of "dotnet run" commands, etc. This is the first place that I have come across in a lot of searching that gives the correct dotnet usage for running a console application. Why did Microsoft make .NET Core so un-developer friendly?

    – Glen Thomas
    Mar 21 '17 at 10:25




    2




    2





    @GlenThomas If you want to run an application you're developing, you use dotnet run. Also, where did you look? Where would you expect this information?

    – svick
    Mar 21 '17 at 12:07





    @GlenThomas If you want to run an application you're developing, you use dotnet run. Also, where did you look? Where would you expect this information?

    – svick
    Mar 21 '17 at 12:07













    "dotnet run" no longer seems to be the case with .NET core projects using the newer MSBuild csproj setup rather than the old project.json files.

    – Glen Thomas
    Mar 21 '17 at 15:09







    "dotnet run" no longer seems to be the case with .NET core projects using the newer MSBuild csproj setup rather than the old project.json files.

    – Glen Thomas
    Mar 21 '17 at 15:09






    1




    1





    @GlenThomas That's not true, dotnet run works the same for the new csproj projects as it did for project.json.

    – svick
    Mar 21 '17 at 16:30





    @GlenThomas That's not true, dotnet run works the same for the new csproj projects as it did for project.json.

    – svick
    Mar 21 '17 at 16:30




    4




    4





    @GlenThomas, not sure if this is the problem you were having, but when you try to use dotnet run, make sure you're in the project directory, not the solution directory.

    – Ryan Lundy
    Dec 12 '18 at 9:52





    @GlenThomas, not sure if this is the problem you were having, but when you try to use dotnet run, make sure you're in the project directory, not the solution directory.

    – Ryan Lundy
    Dec 12 '18 at 9:52













    12














    You can very easily create an EXE (for Windows) without using any cryptic build commands. You can do it right in Visual Studio.




    1. Right click the Console App Project and select Publish.

    2. A new page will open up (screen shot below)

    3. Hit Configure...

    4. Then change Deployment Mode to Self-contained or Framework dependent

    5. If you now view the bin folder in explorer, you will find the .exe file.

    6. You will have to deploy the exe along with any supporting config and dll files.


    Console App Publish






    share|improve this answer





















    • 2





      Yep. There's the EXE - along with 217 other files (api-ms-win-core-namedpipe-l1-1-0.dll, etc). Is there anyway to bundle this down to a single EXE?

      – Elton
      Jan 9 at 16:35






    • 1





      Good question @Elton. I don' know. AFAIK you have to deploy all the dlls.

      – Jess
      Jan 10 at 13:15






    • 1





      I would think the fact that it is configured to be self-contained would require all of those DLLs to be there. If you don't want them there, the deployment mode would probably need to be Framework Dependent

      – kippermand
      Feb 21 at 18:51
















    12














    You can very easily create an EXE (for Windows) without using any cryptic build commands. You can do it right in Visual Studio.




    1. Right click the Console App Project and select Publish.

    2. A new page will open up (screen shot below)

    3. Hit Configure...

    4. Then change Deployment Mode to Self-contained or Framework dependent

    5. If you now view the bin folder in explorer, you will find the .exe file.

    6. You will have to deploy the exe along with any supporting config and dll files.


    Console App Publish






    share|improve this answer





















    • 2





      Yep. There's the EXE - along with 217 other files (api-ms-win-core-namedpipe-l1-1-0.dll, etc). Is there anyway to bundle this down to a single EXE?

      – Elton
      Jan 9 at 16:35






    • 1





      Good question @Elton. I don' know. AFAIK you have to deploy all the dlls.

      – Jess
      Jan 10 at 13:15






    • 1





      I would think the fact that it is configured to be self-contained would require all of those DLLs to be there. If you don't want them there, the deployment mode would probably need to be Framework Dependent

      – kippermand
      Feb 21 at 18:51














    12












    12








    12







    You can very easily create an EXE (for Windows) without using any cryptic build commands. You can do it right in Visual Studio.




    1. Right click the Console App Project and select Publish.

    2. A new page will open up (screen shot below)

    3. Hit Configure...

    4. Then change Deployment Mode to Self-contained or Framework dependent

    5. If you now view the bin folder in explorer, you will find the .exe file.

    6. You will have to deploy the exe along with any supporting config and dll files.


    Console App Publish






    share|improve this answer















    You can very easily create an EXE (for Windows) without using any cryptic build commands. You can do it right in Visual Studio.




    1. Right click the Console App Project and select Publish.

    2. A new page will open up (screen shot below)

    3. Hit Configure...

    4. Then change Deployment Mode to Self-contained or Framework dependent

    5. If you now view the bin folder in explorer, you will find the .exe file.

    6. You will have to deploy the exe along with any supporting config and dll files.


    Console App Publish







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 22 at 20:55

























    answered Jan 4 at 20:41









    JessJess

    13.1k1085117




    13.1k1085117








    • 2





      Yep. There's the EXE - along with 217 other files (api-ms-win-core-namedpipe-l1-1-0.dll, etc). Is there anyway to bundle this down to a single EXE?

      – Elton
      Jan 9 at 16:35






    • 1





      Good question @Elton. I don' know. AFAIK you have to deploy all the dlls.

      – Jess
      Jan 10 at 13:15






    • 1





      I would think the fact that it is configured to be self-contained would require all of those DLLs to be there. If you don't want them there, the deployment mode would probably need to be Framework Dependent

      – kippermand
      Feb 21 at 18:51














    • 2





      Yep. There's the EXE - along with 217 other files (api-ms-win-core-namedpipe-l1-1-0.dll, etc). Is there anyway to bundle this down to a single EXE?

      – Elton
      Jan 9 at 16:35






    • 1





      Good question @Elton. I don' know. AFAIK you have to deploy all the dlls.

      – Jess
      Jan 10 at 13:15






    • 1





      I would think the fact that it is configured to be self-contained would require all of those DLLs to be there. If you don't want them there, the deployment mode would probably need to be Framework Dependent

      – kippermand
      Feb 21 at 18:51








    2




    2





    Yep. There's the EXE - along with 217 other files (api-ms-win-core-namedpipe-l1-1-0.dll, etc). Is there anyway to bundle this down to a single EXE?

    – Elton
    Jan 9 at 16:35





    Yep. There's the EXE - along with 217 other files (api-ms-win-core-namedpipe-l1-1-0.dll, etc). Is there anyway to bundle this down to a single EXE?

    – Elton
    Jan 9 at 16:35




    1




    1





    Good question @Elton. I don' know. AFAIK you have to deploy all the dlls.

    – Jess
    Jan 10 at 13:15





    Good question @Elton. I don' know. AFAIK you have to deploy all the dlls.

    – Jess
    Jan 10 at 13:15




    1




    1





    I would think the fact that it is configured to be self-contained would require all of those DLLs to be there. If you don't want them there, the deployment mode would probably need to be Framework Dependent

    – kippermand
    Feb 21 at 18:51





    I would think the fact that it is configured to be self-contained would require all of those DLLs to be there. If you don't want them there, the deployment mode would probably need to be Framework Dependent

    – kippermand
    Feb 21 at 18:51











    9














    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





    share|improve this answer




























      9














      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





      share|improve this answer


























        9












        9








        9







        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





        share|improve this answer













        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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 7:09









        TequilaTequila

        483419




        483419






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39155571%2fhow-to-run-net-core-console-app-from-the-command-line%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine