8

Right now, I do the following manual steps to run an ASP.NET website on my PC:

  1. Open Visual Studio and the project inside it
  2. Press Ctrl+F5 which:
    1. Builds the solution
    2. Runs IIS express
    3. Opens a browser

How to write a batch file that does the same thing? The last step (opening a browser) is optional but at least I need to build the project and start it on IIS express (or whatever is configured in the project file).

1 Answer 1

13

From the visual studio command line you could do the following:

devenv "C:\path\FooSolution.sln" /run

MSDN Devenv Command Line Switches Reference

Wrapping this all up into a batch file (assuming VS 2012) it would become:

call "C:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" 
devenv "C:\path\FooSolution.sln" /Run

Update

To run this outside of Visual Studio with IIS Express you would use the following commands:

msbuild.exe "C:\path\FooSolution.sln" 
iisexpress /path:c:\path\fooapp\ /port:666
start "" http://localhost:666

Please note there are many configuration options for both msbuild and iisexpress command. You will need to tailor them to suite your needs.

Running IIS Express from the Command Line

Sign up to request clarification or add additional context in comments.

2 Comments

Is there a way to do this without Visual Studio actually starting up? I guess the build could be done by MSBuild so if there is a way to launch IIS Express with the result silently, that would be perfect.
@hutchonoid Is there a way to add projects to my solution from the command line? Thanks in advance :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.