vswhere icon indicating copy to clipboard operation
vswhere copied to clipboard

vswhere could not detect VS2022

Open dharmateja27 opened this issue 2 years ago • 7 comments

When I am running the below script in the PowerShell, vswhere is not able to detect Visual Studio 2022, Visual Studio is not updating.

$vswhere= "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" $vswhereResult = & $vswhere -latest -product * if ($vswhereResult){ $vsLayoutPath = "\server\share\VSlayoutdirectory" & "$vsLayoutPath\vs_professional.exe" --quiet --update --wait --offline & "$vsLayoutPath\vs_professional.exe" update --installPath "vswhereResult" --noWeb --wait --quiet --norestart } else { Write-Host "Visual Studio not found" }

dharmateja27 avatar Oct 10 '23 14:10 dharmateja27

Do you have a preview installed? You need to pass -prerelease? To check if it's in a bad state and needs to be repaired, pass -all and check it's State property. By design, we show neither previews or incomplete instances in default results.

heaths avatar Oct 10 '23 17:10 heaths

I don't have preview installed. I checked the state, it is not in bad state.

dharmateja27 avatar Oct 11 '23 15:10 dharmateja27

Please paste the output of vswhere -all -prerelease.

Also, you're missing a $ above. It should be:

$vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"

Note also that it doesn't exist if VS isn't installed, so you may want to pull it down via nuget e.g., nuget install vswhere -OutputDirectory "${env:TEMP}\vswhere" or something. Better for CIs.

heaths avatar Oct 11 '23 16:10 heaths

vswhere

dharmateja27 avatar Oct 11 '23 17:10 dharmateja27

Did you fix the line that should be:

$vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
write-host "$vswhere"

And check that $vswhere contains what you think? As written in your OP, it's not correct so $vswhereResult wouldn't contain anything, or at error at best.

heaths avatar Oct 11 '23 17:10 heaths

vswhere

dharmateja27 avatar Oct 12 '23 09:10 dharmateja27

You also need to specify you want only the installationPath property:

vswhere.exe -latest -products * -property installationPath

You're passing a bunch of output to the installer so it's erring. You should be checking for errors as well in your script. vswhere appears to be working fine given your previous screenshot.

heaths avatar Oct 12 '23 20:10 heaths