How does Visual Studio Selector Choose the version of Visual Studio to open a Project
I read that the Visual Studio Selector chooses the version of Visual Studio based on the # Visual Studio Version specified in the .sln file. For example, # Visual Studio Version 17 refers to Visual Studio 2022, which controls the version number in the solution icon and indicates the version that most recently saved the file.
If the specified version (e.g., # Visual Studio Version 17) is not installed on my PC, but I have both higher and lower versions of Visual Studio installed, how does the Visual Studio Selector decide which version to use? Will it always choose the higher version, or is there some other logic involved?
Scenario:
I have a project solution File that contains VS 2010 in solution file i.e. # Visual Studio Version 10, But I have Visual basic 2010, VS 2012 , VS 2017 Express Edition installed in my PC. My Visual Studio version selector chose VS 2012 IDE version to open this project, Why? What is the reason behind it ?
Last edited by IT_Researcher; Jan 9th, 2025 at 03:04 AM.
Re: How does Visual Studio Selector Choose the version of Visual Studio to open a Pro
I don't think I understand the question correctly. If you open a solution in VS2022, then VS2022 is the version of VS used to open the solution. If the sln file indicates some earlier version, VS2022 doesn't magically become that earlier version, it's still VS2022.
In older versions, back around 2010 and earlier, each time you opened a solution in a newer version of VS, there was an upgrade process that changed some of the files. This could easily mean that once opened in a newer version of VS, you could no longer open the solution in an older version of VS. Somewhere after 2010, that behavior changed such that opening a solution created in an earlier version of VS didn't change the solution such that you could no longer use that earlier version of VS. The newer version didn't change the solution in such a way that older versions were precluded, but the changes that were being made earlier didn't seem all that significant (unless you changed the targeted framework).
Re: How does Visual Studio Selector Choose the version of Visual Studio to open a Pro
Originally Posted by Shaggy Hiker
I don't think I understand the question correctly. If you open a solution in VS2022, then VS2022 is the version of VS used to open the solution. If the sln file indicates some earlier version, VS2022 doesn't magically become that earlier version, it's still VS2022.
In older versions, back around 2010 and earlier, each time you opened a solution in a newer version of VS, there was an upgrade process that changed some of the files. This could easily mean that once opened in a newer version of VS, you could no longer open the solution in an older version of VS. Somewhere after 2010, that behavior changed such that opening a solution created in an earlier version of VS didn't change the solution such that you could no longer use that earlier version of VS. The newer version didn't change the solution in such a way that older versions were precluded, but the changes that were being made earlier didn't seem all that significant (unless you changed the targeted framework).
Here, I am specifically referring to the Visual Studio Version Selector program. How does it choose an IDE when the version specified in the solution file icon is not installed on my system, but other higher or lower versions are available?
FYI: I am not choosing the IDE manually here.
Re: How does Visual Studio Selector Choose the version of Visual Studio to open a Pro
It appears that it opens the latest version installed. I have VS 2019 and 2022 installed and I just downloaded an old solution from one of my CodeBank threads. When I opened the solution file from File Explorer, VS 2022 opened without additional prompting. I can't test having an earlier version installed but it seems very unlikely that an earlier version would be selected unless there were no later versions installed. In that case, the solution may not open at all, although I don't know whether the VS selector would tell you that or the older VS version that it opened.
Re: How does Visual Studio Selector Choose the version of Visual Studio to open a Pro
Originally Posted by jmcilhinney
It appears that it opens the latest version installed. I have VS 2019 and 2022 installed and I just downloaded an old solution from one of my CodeBank threads. When I opened the solution file from File Explorer, VS 2022 opened without additional prompting. I can't test having an earlier version installed but it seems very unlikely that an earlier version would be selected unless there were no later versions installed. In that case, the solution may not open at all, although I don't know whether the VS selector would tell you that or the older VS version that it opened.
It would be helpful if I could get proper Links/ Blogs/ Articles where the working of Visual studio Version selector is explained for above case. I have also explained a scenario above in my question , please do go thorugh it and help me out if possible.
Last edited by IT_Researcher; Jan 9th, 2025 at 02:44 AM.
Re: How does Visual Studio Selector Choose the version of Visual Studio to open a Pro
Originally Posted by TysonLPrice
When I use the version selector it seems to pick based on the version of the solution not the last installed. If that is what the OP meant:
If the version that created a solution or last upgraded it is installed then it will open in that version. The OP is asking what happens when that version is not installed.
Re: How does Visual Studio Selector Choose the version of Visual Studio to open a Pro
Originally Posted by .paul.
In my experience, the VS Version Selector just opens the .sln in the newest version of VS installed, which is really not what I want it to do…
It will obviously select the version that created or upgraded the solution first but it makes sense to me that, if that's not available, it would select the newest version available. I think that that's what most people would want most of the time. For the remaining cases, there's always 'Open With' in File Explorer or File->Open in VS itself.