2

I have a C# solution that I am developing in Visual Studio. It has a multiple startup projects.

To run it during development, I click the Start button in Visual Studio:

enter image description here

Now I am working on automated testing. I want to start the current code base in an ad hoc environment, the same way I do when I'm developing. I'm assuming there is some way to do this from the command line - some way to do the same thing the Start button does, from the command line. How can I do that?

Update

Thanks to those who have responded so far. My project is a Class Library, so it is outputting DLLs in bin/Debug. It normally launches with IIS, so I'm attempting to duplicate that behavior.

Scotty H
  • 6,432
  • 6
  • 41
  • 94
  • Possible duplicate of [How to compile the finished C# project and then run outside Visual Studio?](https://stackoverflow.com/questions/1057878/how-to-compile-the-finished-c-sharp-project-and-then-run-outside-visual-studio) – mjwills Jul 24 '17 at 21:47
  • 1
    While in VS, what hosts your DLL since of course, a DLL has no entry point? – Bill Roberts Jul 25 '17 at 18:43
  • @flaZer Some magic makes it run in IIS. – Scotty H Jul 25 '17 at 18:49
  • I don't think so... when you "run" in VS, some object needs to marked as the startup project, and within it you need an object that can be started? When running, can you interact with the DLL in any way? – Bill Roberts Jul 25 '17 at 19:08
  • You may want to have a look at the ASP.NET IIS Registration Tool, which is command line driven: https://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx – Bill Roberts Jul 25 '17 at 19:10

3 Answers3

1

What Start does is

  1. Builds the project.
  2. Runs it.
  3. Attaches a debugger

I imagine you care only about 1. and 2.

To build the project, open a Command Prompt in the solution's folder and execute:

msbuild SolutionName.sln /t:ProjectName /p:Configuration=Debug

To run the project, in the same command prompt, you can execute:

cd ProjectName/bin/Debug
ProjectName.exe

Obviously, replace SolutionName and ProjectName with your project's parameters and you can replace the Debug configuration with Release.

Nikola Irinchev
  • 1,911
  • 1
  • 13
  • 17
1

I edited the .csproj file edited to have the following (see this SO):

<UseGlobalApplicationHostFile>True</UseGlobalApplicationHostFile>

and then I rebuilt and ran this from the command line:

"C:\Program Files (x86)\IIS Express\iisexpress.exe" /site:WebSite1

(where WebSite1 is the name of the project), and it seems to work.

See Running IIS Express from the Command Line.

Scotty H
  • 6,432
  • 6
  • 41
  • 94
0
  • Open a command line (Win+R cmd)
  • Change folder (cd XXXX) to your solution folder.
  • Change folder to Debug or Release.
    In those folders should be your exe file, based on your project name.
  • Type in the name of the application
Robert Andrzejuk
  • 5,076
  • 2
  • 22
  • 31