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

Mic*_*sky 7 visual-studio visual-studio-2015

我正在尝试评估Visual Studio 2015 Enterprise,但在安装过程中遇到了一些问题.这是我做的:

  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.
Run Code Online (Sandbox Code Playgroud)

我注意到这些是安装程序中唯一的VSIX软件包.当然,我可以手动安装这些软件包,但我想了解这个错误的原因.

有任何想法吗?

Mic*_*sky 8

介绍

好吧,一周后我发现了它,我有一个解决方案.请记住,如果Microsoft决定更新其安装程序,这可能会有点麻烦.

但首先,我们必须了解问题的根源.

问题

正如我在问题中提到的,安装日志表明由于/noweb交换机而无法下载VSIX软件包.此时一个合理的问题是安装程序首先尝试下载它们的原因.

要回答这个问题,我们必须查看辅助安装程序日志(dd_vs_enterprise_<timestamp>_SecondaryInstaller_UX.log位于%temp%目录中).据我了解,辅助安装程序负责安装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.
Run Code Online (Sandbox Code Playgroud)

这还差不多!现在我们知道失败的真正原因是VSIX上的签名验证!我们现在可以重建事件链:

  1. 安装程序尝试验证VSIX上的签名,但失败.
  2. 安装程序继续从Internet下载VSIX软件包.这里的基本原理可能是签名验证失败,因为缓存的VSIX已损坏,因此再次下载它是唯一的解决方案.
  3. 当然,安装程序再次失败,因为我们不允许所有下载.

但有趣的是,在连接到互联网的机器上,这根本不会发生!即使/noweb指定了开关!

寻找答案

为什么安装在联网计算机上成功,即使不允许所有下载?当无法使用本地可用的证书验证信任时,操作系统的信任验证组件似乎会进入Internet.

微软有一篇关于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上安装时,同样的事情发生了.

也许问题更广泛?过去,Microsoft提供rootsupd.exe了可以在脱机计算机上安装的根证书更新包().虽然最新的软件包甚至可以在Windows 8.1上安装,但它不包括我知道需要的证书.因此,我一直在寻找在断开连接的计算机上安装证书更新的替代方法.

Microsoft在 TechNet文章中介绍了这样做的推荐方法.因为我没有Windows Server计算机,所以我尝试手动应用所需的注册表更改,但无济于事.

Visual Studio的论坛并没有提供太多的帮助,无论是.

但是,在一个突然清晰的时刻,我心想:如果我可以完全避免这个问题怎么办?如果不是试图获取VSIX上的证书来验证,我可以用自己的证书替换这些证书怎么办?毕竟,我处在一个断开连接的环境中,因此信任不是问题.

解决方案

可以使用签名VSIX包vsixsigntool.exe,可在此处获得.幸运的是,可以将已签名的VSIX提供给此实用程序,它将使用您指定的证书替换嵌入的证书.一块蛋糕!

好吧,不完全是.这种方法存在两个问题:

  1. 证书的主题必须是CN = Microsoft Corporation.为什么?安装程序使用特殊的XML"feed"来描述它可用的不同组件(查看OfflineCache\feeds目录).安装VSIX软件包时,它会验证嵌入式证书的主题是否与XML提要中指定的主题相匹配.XML feed也已签名,因此很有趣.
  2. 特殊文件cache.bin为安装程序提供查找程序包的缓存版本所需的信息(例如,参见参考资料OfflineCache\installers\VS_Extensibility_TemplatesV1\cache.bin).问题是,该文件包含包的SHA256哈希.该文件实际上只是一个序列化的.NET对象,但是如果不访问包含序列化对象类的程序集及其成员的类,我们就无法对其进行反序列化.此外,这不是真正的程序员如何做到的!哈希存储为一个简单的ASCII字符串,因此只需搜索和替换即可.

而已!使用此方法,我们可以重新签名所有VSIX包,将用于证书的证书导入受信任的根证书颁发机构存储,并将Bob的叔叔导入.

代码

我编写了一个脚本来执行上面描述的所有操作.它可以在这里找到.玩得开心!