Wednesday, August 22, 2018

Running IISExpress from the command line or Powershell

You don't need to open up Visual Studio just to run another project. You can run IISExpress via the command line instead.

Here is the same example, once for the command prompt and again for Powershell. The name of the site can be found in the applicationhost.config file. You'll see a <site> tag and the name attribute is the siteName. This is also the name that shows up in the system tray when you launch the site in Visual Studio itself.

You can use the system tray IIS Express icon to quit instances started using Powershell or command prompt. You can also type a the letter Q at the command prompt that gets spawned.

Command Prompt

"C:\Program Files (x86)\IIS Express\iisexpress.exe" /config:"C:\dev\MyMvcApp\.vs\config\applicationhost.config" /site:"MyMvcApp"

You'll need to tweak this to match your paths, etc.

Powershell


$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path

function Start-IisExpress($config, $siteName) {
    Start-Process -FilePath 'C:\Program Files (x86)\IIS Express\iisexpress.exe' -ArgumentList "/config:$config /site:$siteName"
}


Start-IisExpress -config "$scriptDir\.vs\config\applicationhost.config" -siteName: "MyMvcApp"

NOTE: This assumes that you have put this in a Powershell (.ps1) file and placed it next to your solution and more importantly that the .vs directory is in the same directory as the .ps1 file. If not, you'll need to adjust the path or hard code the full path.

3 comments:

Unknown said...

Your site is amazing and your blogs are informative and knlowledgeble to my websites.This is one of the best tips in my life.I have in quite some time.Nicely written and great info.Thanks to share the more informations.

Seo Experts
Seo Company
Web Designing Company
Digital Marketing
Web Development Company
Apps Development

galaxy education said...

"https://www.galaxyeduworld.com/courses/bcom-colleges-in-bangalore"Bangalore is home to several prestigious B.Com colleges that provide quality education and a strong foundation for students pursuing a career in commerce. These colleges offer a wide range of specializations such as finance, accounting, marketing, and international business, ensuring students gain the expertise needed to excel in various industries. Renowned institutions like Christ University, Jain University, St. Joseph's College of Commerce, and Mount Carmel College provide excellent academic programs, experienced faculty, and modern facilities. Additionally, many B.Com colleges in Bangalore focus on skill development, industry exposure, and placement opportunities, ensuring that students are well-prepared for the dynamic professional world.

www.galaxyeduworld.com/ said...

Great Article B.Com colleges thanks