-1

I am developed a Win Forms application with C#. The user browses for .NET Projects on his local drive. He/she selects the .NET Projects to open in Web Site Mode.

Functionality (to develop in C#): Is there a possibility, in C# code, to allow the user to open Projects as Web Site Projects in Visual Studio 2008.

Tassisto
  • 9,877
  • 28
  • 100
  • 157

1 Answers1

0

The first thing I'd try is just passing a folder path to devenv and see what happens.

Looking at this page (https://msdn.microsoft.com/en-us/library/19sf6kk3.aspx) it looks like you can use the /Command switch when you launch devenv.exe. Then going into Visual Studio (Tools > Options > Keyboard) I see there's a File.OpenWebSite command. I haven't tried this, but putting those things together I'm assuming you could do something like:

devenv.exe /command "File.OpenWebSite" [path]

The [path] part is going to be the big question mark. The File.OpenWebSite command might just open the dialog in Visual Studio.

You could also take a look at automating the IDE itself, as this post discusses. It's for VS2005 but might still work for newer versions.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/3c8e5b16-b616-4de4-9744-6594be4f474c/automating-opening-of-a-website-in-vs2005?forum=vsx

System.Type type = Type.GetTypeFromProgID("VisualStudio.DTE.9.0", true);
DTE dte = (DTE)System.Activator.CreateInstance(type, true);

VsWebSite.VSWebPackage webPkg = (VsWebSite.VSWebPackage)dte.GetObject("WebPackage");
webPkg.OpenWebSite(path, VsWebSite.OpenWebsiteOptions.OpenWebsiteOption_None, false);
Tassisto
  • 9,877
  • 28
  • 100
  • 157
Craig W.
  • 17,838
  • 6
  • 49
  • 82