none
How to check VS2019 Preview installed or not in our machine by C# Program? RRS feed

  • Question

  • Hi All,

    Already we are using below code in my project to check VS2017 installed or not in machine .

    Issue Description:

    Below code returns VS2017 installed path (C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional) if we have machine with VS2017.

    In VS2019 alone machine ,it returns VS2019 installation path (C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional) properly.

    But, in Both VS2019 and VS2017 installed machine it returns only VS2017 installation path (C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional) ,So we could not find out VS2019 installed or not in both VS (2019 & VS2017 ) installed machine.

    I want to know VS2019 installed path alone by pro-grammatically even my machine has VS2017 and VS2019.

     public string GetVS2017AndHigherInstallationPath()
            {
                try
                {
                    string installedPath = string.Empty;
                    var query = GetQuery();
                    var query2 = (ISetupConfiguration2)query;
                    var e = query2.EnumAllInstances();
                    var helper = (ISetupHelper)query;
                    int fetched;
                    var instances = new ISetupInstance[1];
                    e.Next(1, instances, out fetched);
                    return instances[0].GetInstallationPath();
                }
                catch (Exception ex)
                {
                    return string.Empty;
                }
            }

    Thanks,

    Vijay

    Tuesday, January 8, 2019 12:56 PM

All replies

  •  

    Use FileVersion mixed with Getting the path of a process (look for devenv.exe)

    This should be able to give you the version of Visual Studio based on your usecase, if VS is running.

     
    Tuesday, January 8, 2019 1:55 PM
  • Hi Seyfedsdline

    How can i find  2019 devenv.exe path by registry or any other method's?

    Thanks,

    vijay

    Wednesday, January 9, 2019 6:53 AM
  • Hi Vijay,

    Welcome to the MSDN forum.

    Refer to the description, your issue is about the C# development and our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum for a better support, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, January 9, 2019 7:27 AM
  • You didn't provide the implementation of GetQuery which seems to be the thing that does the lookup. Note that with VS 2017+ simply looking in the registry or whatnot isn't going to work anymore. VS supports multiple instances of VS being installed at the same time and each instance is (mostly) standalone. 

    Beginning with VS 2017 MS recommends that you use vswhere to detect the VS instances installed. It is installed by default to a well-known location as discussed here. You can use it to detect all installed instances of VS 2017+.


    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, January 9, 2019 4:05 PM
    Moderator