microsoft / vssetup.powershell

PowerShell module to interact with Visual Studio Setup
MIT License
233 stars 41 forks source link

Select-VSSetupInstance -Latest - is it about install date or version? #40

Closed nightroman closed 5 years ago

nightroman commented 6 years ago

Select-VSSetupInstance -Latest - is it about install date or version?

The help says

-Latest [<SwitchParameter>]
    Select the most recently installed instance with the highest version (within the optional `-Version` range).

so it is not clear whether it is about date or version.

If we take a look at the code then it looks like it is about installation dates and versions are not checked.

If it is true, is it by design that Latest deals with installation dates, not versions?

In any case, the help might be more clear about what is checked.

NB (Just for cross-reference) Loosely related to this issue https://github.com/nightroman/Invoke-Build/issues/122

heaths commented 6 years ago

"the most recent" means most recently installed, which will have a newer InstallDate. I should be checking for the highest version, and if more than one instance has the same version I should pick the one with the latest InstallDate. But now that you call attention to it, I see it's not sorting based on version like I did in vswhere. I'll get that fixed and make sure I have a test covering it.

pssewell21 commented 5 years ago

@heaths, I have been experiencing an issue where the -Latest flag is picking my VS 2017 instance that was installed after my VS 2019 instance and I believe this discussion is relevant. @Hadronicus appears to have a solution in pull request #53 to this. I noticed that his pull request has been pending approval for over 5 weeks. Are you waiting on something to approve the pull request? Is there additional work that needs to be done for you to approve it that I'm just not seeing communication for? I'm happy to contribute to the effort if needed. Thanks.

heaths commented 5 years ago

To be honest, I missed this somehow. I've merged this and will get the changes published. Thank you for your contribution!

pssewell21 commented 5 years ago

Thank you @heaths and @Hadronicus.

heaths commented 5 years ago

Unfortunately, we're having a publishing issue at the moment I'm trying to sort out. For now, can you expand the ZIP release and make sure all your existing scenarios work? We have code coverage and detected no regressions, but I'd like to get hands on a prerelease before we push a release (once I get all that working again).

pssewell21 commented 5 years ago

I'll be able to test this tomorrow. Thanks for the info.

pssewell21 commented 5 years ago

I've been running into issues getting Visual Studio's installer to update to the newly released version that are currently blocking me from testing this. I'll provide an update as soon as I have one to give.

heaths commented 5 years ago

The installation of our installer is pretty much just deleting a directory (we make a backup), unzip, and run a finalization process. We've not heard reports of this failing. Could you open a feedback ticket from within the Installer (if you still have one installed) or from within Visual Studio if already installed? That will collected relevant data (at least from within the Installer) we'd need to diagnose the issue. But as long as the query API is installed (which actually installs with the products we install so we retain error handling, download robustness, telemetry, etc.) this module will work. I haven't made any significant changes to the query API in many months. Both these cmdlets and vswhere are designed to work with even the original versions of the query API and rarely make use of new features, which we try to use best-effort if necessary.

pssewell21 commented 5 years ago

Here is my feedback ticket: https://developercommunity.visualstudio.com/idea/668905/vs-installer-fails-to-update-from-v213129607-to-v2.html. Thanks.

pssewell21 commented 5 years ago

Update: I installed the prerelease module in my environment. Get-VsSetupInstance gets the following:

DisplayName: Visual Studio Enterprise 2019 InstallationVersion: 16.2.29123.88 InstallDate: 7/31/2019 5:23:27PM

DisplayName: Visual Studio Enterprise 2017 InstallationVersion: 15.9.28307.770 InstallDate: 8/1/2019 3:01:17PM

Get-VsSetupInstance | Select-VsSetupInstance -Latest 

is returning the 2017 instance instead of the 2019 instance as I would expect it should. I'll take a look into the change @Hadronicus made as I would expect that his change would have returned the 2019 instance when the latest flag is used. I'll plan to look at this when I come in tomorrow. Thanks for the pre-release to try out.

heaths commented 5 years ago

I was able to repro the problem and will be sure to add an integration test. The problem occurs when piping instances to Select-VSSetupInstance because records come in one at a time but needed to be sorted all together. If you pass all instances as a single parameter value to Select-VSSetupInstance -Instance it works correctly. As such, all sorting should just be done in EndProcessing. I'll make the changes but we're still having problems publishing at the moment.

pssewell21 commented 5 years ago

@Heaths, any idea what the timeline looks like on getting this change into a released version of the tool? Thanks.

heaths commented 5 years ago

Unfortunately, powershellgallery.com is still giving us issues in production. I've pinged the owner again for a status update.

heaths commented 5 years ago

Reopening until published to keep on my radar.

heaths commented 5 years ago

Okay, finally got the powershellgallery.com issue resolved and https://www.powershellgallery.com/packages/VSSetup/2.2.15-g62f3905dea was published. Can you give that a try and make sure everything is working as expected? Then I can publish a release version.

pssewell21 commented 5 years ago

I'll look into this tomorrow when I get into work. Thanks for the support @heaths

pssewell21 commented 5 years ago

Just tested this and it appears to behave as I would expect in my environment now! Thanks for your assistance @heaths. I apologize for the delayed response, I just got to this.

heaths commented 5 years ago

2.2.16 with this fix has been released.