microsoft / vswhere

Locate Visual Studio 2017 and newer installations
MIT License
921 stars 97 forks source link

vswhere requires -prerelease to detect vs2022 #252

Closed gorlak closed 2 years ago

gorlak commented 2 years ago

Similar to #249, but now vs2022 is released, and the release version is installed (17.0.2 at the time of this writing), the -prerelease flag is still required:

>"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional                                                                                                                                                                                

>"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -prerelease -property installationPath
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
C:\Program Files\Microsoft Visual Studio\2022\Professional
heaths commented 2 years ago

Can you output all the text for VS2022 and paste it here?

gorlak commented 2 years ago

Here you go vswhere.txt

🤔 : isPrerelease: 0

heaths commented 2 years ago

Actually, the bigger problem here seems to be why VS2019 was chosen for -latest over VS2022. In your first example, you added -latest and only one instance will show up. If you exclude that, I imagine VS2022 shows up. Correct?

Can you download and try the latest release to see if that still happens there?

https://github.com/microsoft/vswhere/releases/latest

gorlak commented 2 years ago

Ah, actually yes:

>"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
C:\Program Files\Microsoft Visual Studio\2022\Professional

Actually, I think I wasn't clear on how -latest was intended to work. This wasn't working, and I added latest thinking perhaps vswhere was filtering out 2022 since it was just released. Perhaps it wasn't listed because the installer was install 7.0.2, and it was in pending reboot state or something.

So it seems to be a "latest version sorting" issue of some sort, then?

gorlak commented 2 years ago

Wait, what the hell, it works now:

>"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
C:\Program Files\Microsoft Visual Studio\2022\Professional

That's... strange. 🤔

gorlak commented 2 years ago

I'm going to assume this was a 17.0.1 and lower defect that was fixed w/ reboot after installing 17.0.2

heaths commented 2 years ago

If a reboot was pending for VS2022, it would not be included by default because the product is not in a supported state. Your text output didn't indicate that (there is a state vswhere checks), but if you took that after a reboot, that would be why.

For more information about -latest and other switches, run vswhere with -help.