tags:

views:

648

answers:

5

I am writing a VSPackage for Visual Studio 2008, and am deploying it with a WiX generated Msi. As the end of the install, I am running "devenv.exe /setup" as required to get VS to notice my package. However, this command will not succeed if there are any copies of Visual Studio running.

Currently, I tell people they have to close all copies of Visual Studio before installing, but I would prefer it be foolproof. How can I check when someone runs my .msi if any copies of Visual Studio (devenv.exe) are running, and block them from installing my project?

A: 

You can create an installer class in your project and let it enumerate Running Processes

Akash Kava
Installer classses are nasty.
Rob Mensching
+1  A: 

The WiX toolset has a CloseApps CustomAction that will close windows for you. It unfortuantely does not prompt with a list to close all the applications but the code would be a reasonable place to start.

Rob Mensching
+1  A: 

your best bet is to follow Rob's advide and put together a custom action to check if the process is running. I'd probably do something like see if it's running, try to close, if it's still running then schedule a reboot and do the devenv setup via the RunOnce registry key.

If that's too much work then a bit of an ugly hack would be to use the windows command TASKKILL to exit the application. Not foolproof but it's better than nothing.

TASKKILL /IM devenv.exe
sascha
+1 for not specifying /F ;)
JeffH
+2  A: 
while(devenvIsRunning()) {} //in main routine of Installer class

static bool devenvIsRunning() //uses this subroutine
        {
            Process[] procList = Process.GetProcesses();
            foreach (Process p in procList)
            {
                if (p.ProcessName == "devenv")
                {
                    MessageBox.Show("An instance of Visual Studio is still running.\nPlease close all open instances of Visual Studio before continuing.");
                    return true;
                }
            }
            return false;
        }
muusbolla
+1, but it might be nice to let the user cancel the install instead of suspending it until all the devenvs are shut down.
JeffH
A: 

Hi

The WiX has embedded helper function for this but I'm don't remember the exact names of the functions. Check WiX's documentation

Have a nice day Muse VSExtensions

Muse VSExtensions

related questions