c# - How to run windows form application by cmd -


i created windows form application vs 2017. there 3 files, program.cs, form1.designer.cs, form1.cs. want compile , run through cmd. tried type csc /out:program.exe program.cs doesn't work.

the error :

cannot find namespace or class 'form1'.

the application work in vs2017 not in cmd. can tell me how compile , run application through cmd?

you should compile classes , not 1 on visual studio command prompt:

csc.exe *.cs /target:winexe /out:program.exe  

if want create output exe in bin directory of project's root directory can try below command. need ensure bin directory present before firing command. command not create bin directory on own if not present.

csc.exe  *.cs /target:winexe /out:.\bin\program.exe 

note: /target switch helps launch output exe windows forms application. don't mention switch launched console application first in turns lunches windows application.

an alternative option try msbuild command in place of csc command on visual studio command prompt:

msbuild windowsformsapplication1.csproj 

here need project name (*.csproj) in place of individual class files names command-line parameters. msbuild command takes care of creating sub directories bin, debug if not present.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -