Visual Studio 2015企业版离线安装失败

7

我试图评估Visual Studio 2015企业版,但在安装过程中遇到了一些问题。以下是我所做的:

  1. 使用/layout开关下载完整的安装程序。
  2. 使用/NoWeb开关启动安装程序。

为此目的,我使用一个干净的Windows 8.1虚拟机,以免损坏我的主机系统。该虚拟机未连接到网络。

在日志中出现以下条目,导致安装失败:

MUX:  ExecuteError: Package (VSSecondaryInstaller_box) failed: Error Message Id: 1603 ErrorMessage: Visual Studio Extensibility Item Templates with Assembly References in Nuget Packages : This product did not download successfully: Unable to download 'http://go.microsoft.com/fwlink/?LinkId=558768'.  Web downloads are not allowed when the /NoWeb switch is used.
MUX:  ExecuteError: Package (VSSecondaryInstaller_box) failed: Error Message Id: 1603 ErrorMessage: GitHub Extension for Visual Studio : This product did not download successfully: Unable to download 'http://go.microsoft.com/fwlink/?LinkId=616986'.  Web downloads are not allowed when the /NoWeb switch is used.
MUX:  ExecuteError: Package (VSSecondaryInstaller_box) failed: Error Message Id: 1603 ErrorMessage: PowerShell Tools for Visual Studio : This product did not download successfully: Unable to download 'http://go.microsoft.com/fwlink/?LinkID=616995'.  Web downloads are not allowed when the /NoWeb switch is used.

我注意到这些是安装程序中的唯一VSIX包。当然,我可以手动安装这些包,但我想了解此错误的原因。
有任何想法吗?

只是一个提醒:在安装Visual Studio 2017离线版本时遇到相同的问题,但是离线缓存中的"certificates"文件夹中也有所需的证书,请导入它们并重新启动安装程序,一切都会正常。 - Vijay
3个回答

9

介绍

好的,一周后我已经找到了解决方案。请注意,这个方法有点hacky,如果微软决定更新他们的安装程序可能会失败。

但首先,我们必须理解问题的根源。

问题

如我在问题中提到的,安装日志显示由于/noweb开关,无法下载VSIX包。此时一个合理的问题是为什么安装程序首先尝试下载它们。

要回答这个问题,我们必须查看Secondary Installer日志(dd_vs_enterprise_<timestamp>_SecondaryInstaller_UX.log,位于%temp%目录内)。据我所知,Secondary Installer负责安装所有与Visual Studio一起提供的额外包。这个日志可以澄清一些问题。

DownloadManager Information: 0 : Using cached file at C:\ProgramData\Microsoft\VisualStudioSecondaryInstaller\14.0\installers\VS_Extensibility_TemplatesV1\en\0\Microsoft.Vsix.TemplatesPackage.vsix instead of downloading from http://go.microsoft.com/fwlink/?LinkId=558768
DownloadManager Error: 0 : Signature verification failed on downloaded file. URL: http://go.microsoft.com/fwlink/?LinkId=558768. File location: C:\ProgramData\Microsoft\VisualStudioSecondaryInstaller\14.0\installers\VS_Extensibility_TemplatesV1\en\0\Microsoft.Vsix.TemplatesPackage.vsix. File size: 3965 kb
DownloadManager Error: 0 : BITS download failed. Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Web.PlatformInstaller.InstallManager.BITSDownloadInstallerFile(InstallerContext currentInstall, String& failureReason, String& failureErrorCode, Boolean& downloadNotAllowed, Boolean setFinalReturnState)
DownloadManager Warning: 0 : BITS failure: BITS download failed. BITS service may have been disabled on the machine.. Retrying download for 'Visual Studio Extensibility Item Templates with Assembly References in Nuget Packages'
DownloadManager Warning: 0 : WinInet failure: Unable to download 'http://go.microsoft.com/fwlink/?LinkId=558768'.  Web downloads are not allowed when the /NoWeb switch is used.. Retrying download for 'Visual Studio Extensibility Item Templates with Assembly References in Nuget Packages'
DownloadManager Information: 0 : WebClient downloading file 'http://go.microsoft.com/fwlink/?LinkId=558768' to: C:\Users\John Gallegos\AppData\Local\Temp\evlyeg3i.fmr
DownloadManager Error: 0 : WebClient error while downloading file 'http://go.microsoft.com/fwlink/?LinkId=558768'. Exception: System.Net.WebException: The remote name could not be resolved: 'go.microsoft.com'
   at System.Net.WebClient.OpenRead(Uri address)
   at Microsoft.Web.PlatformInstaller.InstallManager.WebClientDownloadInstallerFile(InstallerContext currentInstall, String& errorMessage, Boolean setFinalReturnState)
DownloadManager Warning: 0 : WebClient failure: The remote name could not be resolved: 'go.microsoft.com'. Retrying download for 'Visual Studio Extensibility Item Templates with Assembly References in Nuget Packages'
DownloadManager Warning: 0 : WinInet failure: Unable to download 'http://go.microsoft.com/fwlink/?LinkId=558768'.  Web downloads are not allowed when the /NoWeb switch is used.. Retrying download for 'Visual Studio Extensibility Item Templates with Assembly References in Nuget Packages'
DownloadManager Error: 0 : BITS failure: Unable to download 'http://go.microsoft.com/fwlink/?LinkId=558768'.  Web downloads are not allowed when the /NoWeb switch is used.. Download failure for Visual Studio Extensibility Item Templates with Assembly References in Nuget Packages.

这才像样!现在我们知道失败的真正原因是VSIX签名验证!我们可以重构事件链:
1. 安装程序尝试验证VSIX的签名,但失败了。 2. 安装程序继续从互联网下载VSIX包。这里的理由可能是签名验证失败是因为缓存的VSIX文件已损坏,所以重新下载是唯一的解决方法。 3. 当然,安装程序再次失败,因为我们禁止所有下载。
但有趣的是,在连接到互联网的机器上,这根本不会发生!即使指定了/noweb开关!
寻找答案
为什么在网络化的机器上安装成功,即使禁止所有下载?似乎操作系统的信任验证组件在无法使用本地可用证书进行信任验证时,会访问互联网。
微软有一个关于VS 2015已知问题和修复错误的知识库文章(在此处),似乎支持我的理论。以下是文章内容:
如果您未将Windows Update选项设置为自动更新根证书,并选择安装可选组件,则在进程结束时,您会收到以下Visual Studio设置警告:PowerShell Tools for Visual Studio: This product did not download successfully: Signature verification failed on downloaded file.如果关闭了自动更新,则计算机将无法拥有最新的根证书。因此,Visual Studio设置将无法识别用于签署VSIX文件的证书作为有效证书,并且将不安装组件。
起初,我以为我找到了我要找的东西。我们所要做的就是获得正确的证书,然后完成它!但是你该如何做呢?使用certmgr.msc对成功安装了VS 2015的网络计算机进行已安装证书的差异比较,提供了几个似乎负责我的问题的证书。然而,在断开连接的计算机上手动安装它们并没有产生任何结果。您可以查看我关于此问题的问题,但它与安装无关:当我尝试在Windows 10上安装时发生了同样的情况。
也许问题更广泛?过去,微软提供了可以安装在离线机器上的根证书更新包(rootsupd.exe)。尽管最新的包可以安装在Windows 8.1上,但它不包括我知道所需的证书。因此,我开始寻找在断开连接的机器上安装证书更新的替代方法。
微软在TechNet文章this中描述了推荐的操作方式。因为我没有Windows Server机器,我尝试手动应用所需的注册表更改,但无济于事。 Visual Studio论坛也没有提供太多帮助。
但是,在一个突然清晰的时刻,我想到了:如果我可以避免这个问题呢?如果我能用自己的证书替换那些VSIX的证书,而不是试图使证书验证通过呢?毕竟,我处于一个断开连接的环境中,因此信任并不是问题。

解决方案

可以使用vsixsigntool.exe对VSIX包进行签名,此处提供下载。幸运的是,可以将已经签名的VSIX文件输入到此工具中,并用指定的证书替换嵌入式证书。非常简单!

但实际上并不是这样。这种方法存在两个问题:

  1. 证书的主题必须是 CN = Microsoft Corporation。为什么?安装程序使用一个特殊的 XML "feed" 来描述它可用的不同组件(查看 OfflineCache\feeds 目录)。安装 VSIX 包时,它会验证嵌入式证书的主题是否与 XML feed 中指定的主题匹配。XML feed 也被签名了,所以好玩的事情都在这里。
  2. 一个特殊的文件 cache.bin,为安装程序提供查找包的缓存版本所需的信息(例如,OfflineCache\installers\VS_Extensibility_TemplatesV1\cache.bin)。问题是,该文件包含包的 SHA256 哈希值。该文件实际上只是一个序列化的 .NET 对象,但我们没有访问包含序列化对象类和其成员类的程序集的权限,因此不能对其进行反序列化。另外,这也不是“真正的程序员”的做法!哈希值存储为简单的 ASCII 字符串,所以只需要进行搜索和替换即可。

就是这样!使用这种方法,我们可以重新签名所有的 VSIX 包,将使用的证书导入到可信任根证书颁发机构存储,并轻松搞定。

代码

我写了一个脚本,可以执行我上述描述的所有操作。你可以在这里找到它。祝你玩得愉快!

2
这个问题的原因是机器需要每个文件使用的证书的最新撤销列表。如果没有安装最新的CRL,它需要使用互联网进行检查。
随着更新2的发布,微软更新了Visual Studio的辅助安装程序,如果机器处于离线状态,则不会检查VSIX扩展的证书撤销列表。这解决了本主题中描述的问题。
他们还最近发布了一篇文章,其中包含有关离线安装的说明https://msdn.microsoft.com/en-us/library/mt706497.aspx。 "故障排除离线安装"部分包含使用特殊源创建布局来解决离线安装问题的信息。

这帮助我解决了这个问题,但我不得不单独下载该源,将其复制到本地,然后使用传统路径(如c:\blah\feed.xml)引用feed.xml。随着更新的证书吊销列表,离线安装程序正常工作。 - Paully

0

安德森·卡西米罗先生的回答为我提供了一些非常好的线索,帮助我解决了离线安装时由证书验证错误引起的问题。

总结: 基本上,我需要获取最新的证书吊销列表副本,并将其安装到我的离线系统中:

http://crl.microsoft.com/pki/crl/products/MicCodSigPCA_08-31-2010.crl

http://www.microsoft.com/pkiops/crl/MicCodSigPCA2011_2011-07-08.crl

http://crl.microsoft.com/pki/crl/products/MicrosoftTimeStampPCA.crl

http://crl.microsoft.com/pki/crl/products/MicTimStaPCA_2010-07-01.crl

http://crl.microsoft.com/pki/crl/products/CSPCA.crl

http://crl.microsoft.com/pki/crl/products/tspca.crl

http://crl.comodoca.com/COMODOCodeSigningCA2.crl

http://crl.comodoca.com/COMODORSACodeSigningCA.crl

http://crl.usertrust.com/UTN-USERFirst-Object.crl

http://crl.microsoft.com/pki/crl/products/MicCodSigPCA_2010-07-06.crl

http://ts-crl.ws.symantec.com/tss-ca-g2.crl

有两个包无论安装了多少CRLs,我都无法使证书验证通过:

sqlcmdlnutils_amd64\SqlCmdLnUtils.msi

DotFuscator

安装VS 2012后,您可以直接进入这些工具的软件包文件夹并安装它们。

CRLs 可能在24小时内有效,或者根据您的CRL缓存超时时间设置。因此,如果您需要在几天后在另一台系统上安装,则必须在其他系统上下载并安装最新的CRL。


我在下面写出了我所采用的更长的故障排除步骤。

症状:Visual Studio安装程序指示未能安装一个或多个软件包,并要求您指定软件包可执行文件的位置。您在安装介质的packages目录中指定位置,但它再次提示您。

第1步:确定是否为证书问题

您可以右键单击Visual Studio可执行文件并单击属性。在数字签名选项卡下,选择其中一个签名并单击详细信息。

在数字签名信息下,如果没有显示“此数字签名无误。”,则可能存在签名问题。

此外,您可以检查c:\Users[username]\AppData\Local\Temp目录中是否有名为dd_vs_professiona_[Timestamp].log 的文件,并注意日志中是否存在证书验证错误。

第2步:解决证书问题

a. 如果错误指示证书不受信任:

Ensure that all the certificates from the digital signature are trusted.

1) Launch the Certificates MMC for your local computer by:
  -Open command prompt as admin and type mmc and enter.
  -File -> Add Remove SnapIn
  -Select Certificates and click add
  -Select Computer Account and click Next.  
  -Select Local Computer and click Finish.

2) 回到Visual Studio可执行文件对话框。

单击Visual Studio可执行文件,然后单击属性。在数字签名选项卡下,选择其中一个签名,然后单击详细信息。

单击查看证书。单击证书路径选项卡。

3) 如果证书路径中有一个不受信任的证书,请单击它,然后查看证书。单击详细信息,然后单击复制到文件。将证书保存到易于找到的位置。

4) 返回证书MMC。导航到受信任的根证书。右键单击 -> 所有任务 -> 导入

5) 导入您刚刚保存到文件的证书。

您必须为证书路径中的所有证书执行此操作。

b. 如果错误指示无法验证CRL。

单击Visual Studio可执行文件,然后单击属性。在数字签名选项卡下,选择其中一个签名,然后单击详细信息。

1. Click View Certificate
2. Under Details Tab -> Click CRL Distribution Points
3. Download the crl from the URL specified in the CRL Distribution Points.
4. Copy the file to your offline system.
5. Right click on it and Click Install CRL, Next, Next, Finish.

请参见上面的摘要部分,了解我必须下载的CRL列表。

c. 如果错误提示为“其中一个计数签名无效。文件可能已被更改。”,则:

单击Visual Studio可执行文件,然后单击属性。 单击数字签名。单击签名,然后单击详细信息。

  • 不要单击数字签名的查看证书,而是单击计数签名部分下的时间戳。

-单击详细信息,然后单击时间戳证书的查看证书 -在详细信息选项卡中单击CRL分发点

-下载时间戳crl。 -将其复制到您的离线系统中,右键单击crl文件并安装crl,然后依次单击下一步,下一步,完成。

请参见上面的摘要部分,了解我必须下载的CRL列表。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接