Right now, I do the following manual steps to run an ASP.NET website on my PC:
- Open Visual Studio and the project inside it
- Press Ctrl+F5 which:
- Builds the solution
- Runs IIS express
- 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).
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
From the visual studio command line you could do the following:
devenv "C:pathFooSolution.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 FilesMicrosoft Visual Studio 11.0Common7ToolsVsDevCmd.bat" devenv "C:pathFooSolution.sln" /Run
Update
To run this outside of Visual Studio with IIS Express you would use the following commands:
msbuild.exe "C:pathFooSolution.sln" iisexpress /path:c:pathfooapp /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
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0