C# publishing an .exe and sending params to it using cmd

你离开我真会死。 提交于 2021-02-04 15:43:27

问题


i am pretty sure this is basic but i just dont success to do this i am trying to create a console application that would do ABC by getting few arguments

for start i am trying to run something as simple as that

static void Main(string[] args)
{
    foreach (var s in args)
    {
        Console.WriteLine(s);
    }
    Console.ReadLine();
} 

when i publish it it comes at as a 'clickonce' project like NAME.application instead of NAME.exe

also , when i am trying to go execute it with XYZ parms like trying in same folder in command line

NAME.application agr1 agr2 agr3

it just opens the application with empty console :(


回答1:


The .application file is not your executable file, but a file used for the deployment. So when running the program locally, you should still run the .exe. file. Check here for some info about command line arguments and ClickOnce: "Simulating command line parameters in Click Once applications"




回答2:


By "publishing" your application from Visual Studio, you are making it into a ClickOnce application. If you only need a simple command line application without the ClickOnce features, just deploy your application using xcopy. That is, just copy the exe and dll files from your bin directory to any directory on the computer where you want to "deploy" it.

In case you need it to be a ClickOnce application, refer to @Fredrik Mörk and @taspeotis answers.



来源:https://stackoverflow.com/questions/4358201/c-sharp-publishing-an-exe-and-sending-params-to-it-using-cmd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!