Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vswhere could not detect VS2022 #301

Open
dharmateja27 opened this issue Oct 10, 2023 · 7 comments
Open

vswhere could not detect VS2022 #301

dharmateja27 opened this issue Oct 10, 2023 · 7 comments

Comments

@dharmateja27
Copy link

dharmateja27 commented Oct 10, 2023

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"
}

@heaths
Copy link
Member

heaths commented Oct 10, 2023

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.

@dharmateja27
Copy link
Author

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

@heaths
Copy link
Member

heaths commented Oct 11, 2023

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.

@dharmateja27
Copy link
Author

vswhere

@heaths
Copy link
Member

heaths commented Oct 11, 2023

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.

@dharmateja27
Copy link
Author

vswhere

@heaths
Copy link
Member

heaths commented Oct 12, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants