Handy Andy Mutter
Handy Andy Mutter

Reputation: 304

Open a visual studio website (not solution) from the command line

I have created a console app using visual studio to run patch files against our websites.

After the patches have been applied what I want to do is to open the website in visual studio and run it.

The problem I have is that the sites I have are not 'projects' or 'solutions'. I have tried using the following command but it opens the site as a solution and adds in lots of .vs files and it doesn't run.

(devenv /command \"File.OpenWebSite\" project.rootFolder);

Basically what I am asking is; Is there a way to open a website without opening it as a solution? From what I can see File.OpenWebsite should be doing what I want...

Any help would be great, Thanks in advance

Upvotes: 0

Views: 137

Answers (1)

Jaskier
Jaskier

Reputation: 1095

If you're able to browse to the website using your internet browser, you can use System.Process.Start() in order to open it:

using System;
using System.Diagnostics;

 string browserPath = @"C:\Program Files\Mozilla Firefox\firefox.exe"; //or whatever browser you use
 string website = @"google.com"; //replace with your actual website

 Process.Start(browserPath, website);

Add this at the end of your program and it should work just fine. If your website is just a file (instead of url), replace google.com with the full file path to your website file (.html, etc).

Upvotes: 1

Related Questions