0

How do I export or execute a console application form project, or find somewhere something like the .exe file of my console application?

The reason I ask this is to run my project (C#) without using Visual Studio debugging.

I found it in \bin\Debug, but it closes and I can't read the output... Is there a way to suspend the answer somehow?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Gio
  • 81
  • 1
  • 2
  • 9

3 Answers3

6

Visual Studio puts the EXE file in the folder <ProjectDirectory>\bin\Debug.

If your console application closes immediately after you double clicked it with your mouse, start it from the command prompt or put code as shown below at the end of your main method:

Console.WriteLine("Hit Enter to quit");
Console.ReadLine();
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kai
  • 1,953
  • 2
  • 13
  • 18
  • i found it \bin\Debug but it closes and i cant read... is there a way to suspend the answer somehow? – Gio Apr 26 '13 at 17:45
  • if i would run this program on other pc, how is it possible? i extracted console app folder to the other computer but it didn't work – Gio Apr 28 '13 at 16:29
  • how to make that special ".exe" file work on other pc even if there won't be visual studio. is there any solution? – Gio Apr 28 '13 at 16:30
  • @Gio: The PC needs the .NET Framework. The version depends on the version you've used during the development. – Kai Apr 28 '13 at 17:19
1

When you build your project, Visual Studio will create an EXE file in bin\Debug.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

Check this code sample:

Build Visual Studio project through the command line

This will give you a little mini "build script". You can build your code without opening up Visual Studio.

Here is the code from the URL:

Create a .bat file called: Manual_MSBuild_ReleaseVersion.bat

Put this in the .bat file.

rd .\BuildResults /S /Q
md .\BuildResults


REM set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v3.5
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
call %msBuildDir%\msbuild.exe  MySolution.sln /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_LOG.log
set msBuildDir=

XCOPY .\MyProject\Bin\Release\*.* .\BuildResults\

You can build a .sln file or a .csproj file. MySolution.sln or MyProject.csproj

See How to: Use MSBuild to Create a Web Package for more information.

That way, you remove a directory (just to make sure you get a super clean build), create it, build the solution/project and then copy the results of the build to the fresh directory.

Super fresh, every time. And if the build blows up, the \BuildResults directory is empty.

And a subtle little indicator, the datetime of the \BuildResults directory is the last time you built (or tried to build) the solution/project. Subtle, but sometimes helpful.

Community
  • 1
  • 1
granadaCoder
  • 26,328
  • 10
  • 113
  • 146