You should compile all your classes and not just one on Visual Studio command prompt:
csc.exe *.cs /target:winexe /out:Program.exe
If you want to create the output exe in bin
directory of your project's root directory then you can try below command. You need to ensure that bin
directory is already present before firing the command. This command will not create bin
directory on its own if not present.
csc.exe *.cs /target:winexe /out:.\bin\Program.exe
Note: /target
switch helps your launch the output exe as a windows forms application. It you don't mention this switch then it will get launched as console application first which in turns lunches the windows application.
An alternative option is to try msbuild
command in place of csc
command on Visual Studio command prompt:
msbuild WindowsFormsApplication1.csproj
Here you need the project name (*.csproj) in place of individual class files names as command-line parameters. msbuild
command also takes care of creating any sub directories like bin
, debug
if not present.