Bug 54807 - "Xamarin for Visual Studio Updates" dialog does not give the user a way to get past "This installation package could not be opened" if one of the .msi files has an incorrect MD5 checksum after it finishes downloading
Summary: "Xamarin for Visual Studio Updates" dialog does not give the user a way to ge...
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Updater ()
Version: 4.3.0 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jose Gallardo
URL:
: 56802 ()
Depends on:
Blocks:
 
Reported: 2017-04-07 21:56 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2017-05-31 18:18 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2017-04-07 21:56:23 UTC
"Xamarin for Visual Studio Updates" dialog does not give the user a way to get past "This installation package could not be opened" if one of the .msi files has an incorrect MD5 checksum after it finishes downloading


At first glance, this might sound like a bit of an unusual scenario, but it seems that the new CDN servers that have been in use recently for Xamarin downloads have significantly increased the likelihood of ending up with an incorrect download (probably more likely in certain geographical regions):

> 1 unique user  (2017-04-07): https://forums.xamarin.com/discussion/comment/264847/#Comment_264847
> 3 unique users (2017-03-29): https://forums.xamarin.com/discussion/91853/xamarin-vs-update-4-3-0-795-fails-to-install
> 1 unique user  (2017-03-16): https://forums.xamarin.com/discussion/comment/259704/#Comment_259704





## Steps followed to test


1. Install a version of XamarinVS that is older than a version in one of the updater channels.


2. Navigate to "Tools > Options > Xamarin > Other" and use the "Check Now" link.


3. Click the "Download" button to start the download.


4. Replace the downloaded file with a file that is not a valid .msi.  For example, move the original file out of the way.  Moving the file is sufficient, but if you like, you can optionally also create a new empty text file with the same name in the downloads folder:

%LOCALAPPDATA%\MonoDevelop-4.0\Cache\TempDownload


5. Now go back into the update menu (as in step 2) and click the "Install" button.




## Results

A windows error dialog message appears:

> This installation package could not be opened.  Contact the
> application vendor to verify that this is a valid Windows Installer
> package.



## Possible improvements


Extend the actions performed by the "Install" button to:

a. Check the MD5 sum of the .msi file against the `<Hash>` value stored in the corresponding .index.xml file.  If the MD5 sum matches, proceed as normal.  Otherwise continue to (b).

b. Display a dialog message indicating that the .msi appears to have downloaded incorrectly and instructing the user to "please try again."  Draft wording:

The downloaded installer for $PRODUCTNAME appears to be incomplete based on the checksum of the file. Click OK to remove the invalid file, and then please try the download once more.

[OK] [Cancel]

c. Delete .msi and the .index.xml file.

d. Return the user to the "Download" step of the "Xamarin for Visual Studio Updates" dialog.
Comment 2 Slava Osipov 2017-05-17 10:03:59 UTC
Issue can be reproduced when step 4 replaced with:
4. Disable network adapter or unplug newtwork cable before downloading finish.
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-26 16:50:49 UTC
## Tallying additional reports for bookkeeping

> 4 unique users (2017-05-26): https://forums.xamarin.com/discussion/96095/stable-channel-except-vs-2017-15-2-2-service-release/p1
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-26 17:30:21 UTC
## Alternate possible improvements

- Perhaps the download server offers some additional information that could be taken into account by the XamarinVS extension to successfully pause and resume the download more often?

- I'll also check with the Xamarin team about whether the CDN server behavior in these scenarios is something particularly unexpected where the CDN team might be able to help.
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-26 17:32:08 UTC
*** Bug 56802 has been marked as a duplicate of this bug. ***
Comment 6 xamarin-release-manager 2017-05-31 13:39:11 UTC
Fixed in version 4.6.0.190 (master)

Author: josegallardo
Commit: 69abbf7a7bbeda0a901b37a0bef39a62eccf9410 (xamarin/XamarinVS)
Comment 7 Jose Gallardo 2017-05-31 13:48:42 UTC
To clarify about the "fix" on Comment 6:

Looking into this issue, we've found that after a failed download, the updater was not providing feedback until trying to install the corrupted file. The MD5 check at the end of the download was performed, but the error message was wrongly getting lost giving the impression that the download succeeded.
At that point (when a download failed, or if the temp msi file was deleted or corrupted) there was no way to restart the download unless manually deleting the files (both the msi and xml) from the temp location.

Fix:
The commit includes the following improvements to get back from a failed download

It shows the failed download as failed in the list (fixing the message getting lost).
When a download fail, the updater tries to finish the other downloads, but after finishing *trying* to download all the files, if there was at least a failed one, the Download button is shown again, allowing the user to retry the download.
Before trying to install the files (i.e. if after the download the user has closed VS, and in a different session tried to install them from the Updater window), it checks the MD5 again to ensure the files were successfully downloaded and were not removed/changed before trying to install them.
While checking the MD5, the download/install button is disabled to avoid issues.
If any issue is found, the Download button allows the user to download the failed/missing file.

This fix is all on the Visual Studio extension side. It doesn't improve the CDN/download process itself.
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-31 18:18:09 UTC
That sounds excellent.  Thanks!