You may receive the following error while installing SQL Server 2017 or upgrading your SQL server from the previous version:
Microsoft SQL Server 2017 Setup
The following error has occurred:
VS Shell installation has failed with exit code 1638.
For help, click: https://go.microsoft.com/fwlink?
LinkID=20476&ProdName=Microsoft%20SQL%20Server&EvtSrc=setup.rll
&EvtID=50000&ProdVer=14.0.1000.169&EvtType=0x5B39C8B9%25401434%25403

Solution
This issue is caused by Microsoft Visual C++ 2017 Redistributable (x86) and (x64) or Microsoft Visual C++ 2015 Redistributable (x86) and (x64) packages. During SQL Server 2017 installation, it tries to install Microsoft Visual C++ 2015 Redistributable. If you have higher version of this package, installation will be failed with above error message.
To fix this error, you need to uninstall Microsoft Visual C++ 2017 Redistributable (x86) and (x64) or Microsoft Visual C++ 2015 Redistributable (x86) and (x64) from your system and then try again to install SQL server 2017.
Following are the direct link to download Microsoft Visual C++ 2017 Redistributable packages:
X64: https://go.microsoft.com/fwlink/?LinkId=746572
x86: https://go.microsoft.com/fwlink/?LinkId=746571
If you are upgrading from SQL Server 2016 to SQL Server 2017, you may receive the same error message. The above solution is still valid for upgrade as well.