【问题标题】:Visual Studio 2019 Offline Layout Update ignoring '--noUpdateInstaller'Visual Studio 2019 离线布局更新忽略“--noUpdateInstaller”
【发布时间】:2020-06-08 09:42:30
【问题描述】:

我们使用“Visual Studio Offline Layout” 将 VS 16.6 部署到具有混合互联网连接(离线/代理/直接)的开发人员和构建服务器。直到最近,以前的 VS 实例(确切地说是 16.3)中的 installation/update 运行良好。

目前,我们无法再使用离线布局安装本地缓存版本的 Visual Studio,因为连接到 Internet 的计算机需要在安装任何东西之前更新“Visual Studio 安装程序”。

vs_Professional.exe update --wait --norestart --noweb --noUpdateInstaller ... 的调用在调用后很快就失败了,退出代码为“1”。 查看 TEMP 中的dd_ 日志,我们发现:

VisualStudio Bootstrapper:08.06.2020 10:17:49: Starting VS setup process 'vs_installer.exe' with arguments ' --layoutPath "<unc_path>\vs2019_250520_layout" --in "\<unc_path>\vs2019_250520_layout\Response.json" update --passive --norestart --productkey ;-) --nocache --noUpdateInstaller --noWeb --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.NetCoreTools --add Microsoft.VisualStudio.Workload.Node --add Microsoft.VisualStudio.Component.VC.v141.MFC --includeOptional --includeRecommended --addProductLang en-us --locale de-DE --activityId "2e4fbc9e-37da-4791-9228-11b9649b69fa" --pipe "d549be32-ee39-49d5-b871-bed44625cafb"'.
VisualStudio Bootstrapper:08.06.2020 10:17:49: VS setup process C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe started. All done.
VisualStudio Bootstrapper:08.06.2020 10:17:49: Waiting for setup process to complete...
VisualStudio Bootstrapper:08.06.2020 10:17:54: Pipe disconnected.
VisualStudio Bootstrapper:08.06.2020 10:17:56: VS setup process exited with code 1
VisualStudio Bootstrapper:08.06.2020 10:17:56: Bootstrapper failed with client process error or unknown error.

在调用 Visual Studio 安装程序时,我们已经在使用 --noweb and --noUpdateInstaller 标志,这让我认为这些参数没有正确处理。

有没有办法真正强制--noUpdateInstaller,Visual Installer 也可以在更新 Visual Studio 之前离线更新吗?


编辑:此问题的可能解决方法是确定目标工作站是否连接到互联网 - 并根据此检查的结果指定使用“--noUpdateInstaller”。

即在我们的部署脚本中:

$hasInternetConnection = try {
  $request = [System.Net.WebRequest]::Create( "http://microsoft.com" )
  $response = $request.GetResponse()
  $response.StatusCode -eq 200
}
catch {
  $false
}

# use '--noUpdateInstaller' iff we are not connected to the internet!
$updateInstaller = if ($hasInternetConnection) {
  ""
}
else {
  "--noUpdateInstaller"
}

$packageArgs = @{
  packageName    = $packageName
  fileType       = 'EXE'
  file           = $(Join-Path $layoutPath "vs_Professional.exe")
  softwareName   = 'Microsoft Visual Studio 2019 Professional'

  silentArgs     = "$setupPrefix --passive --norestart --wait --productkey $productKey --nocache $updateInstaller --noWeb $selectedWorkloads --includeOptional --includeRecommended --addProductLang en-us"
  validExitCodes = @(0, 3010)
}

Install-ChocolateyInstallPackage @packageArgs

【问题讨论】:

    标签: visual-studio installation visual-studio-2019


    【解决方案1】:

    不幸的是,--noUpdateInstaller 开关具有很大的误导性,并没有完全按照其名称所暗示的那样工作。

    Visual Studio 的“离线安装程序”只有在您的计算机没有连接到互联网时才能真正离线工作,否则它将始终联系 MSFT 并检查是否有可用更新,至少对于安装程序 @987654323 @ 本身。如果您没有连接到 Internet,则需要指定 --noUpdateInstaller 以忽略无法检查更新的错误。

    create-a-network-installation-of-visual-studio 上的“提示”说

    如果您想从非 Internet 上的离线源安装 连接的计算机,指定 --noWeb 和 --noUpdateInstaller 选项。前者阻止下载更新的工作负载, 组件等。后者可防止安装程序 通过网络自行更新。

    缺少的是,如果安装程序的较新版本可用退出代码为“1”,则命令执行实际上会失败。 这似乎被设计破坏了,但可以通过对您的安装/部署/升级脚本进行小的修改来解决。


    解决方法 #1 - 始终尝试先升级 vs_installer,然后使用离线布局

    (用于将 VS 部署到主机的示例 PowerShell 脚本,注意:从 UNC 共享调用 vs_professional.exe!)

    # let the magical vs_installer be updated, if vs has already be installed previously
    
    if (Test-IsVSAlreadyInstalled) {
      try {
        vs_professional.exe --quiet --update --wait
      } catch {
        Write-Host "failed to update magical vs_installer"
      }
    }
    
    # only pass "update" if VS is already installed
    $updatePrefix = if (Test-IsVSAlreadyInstalled) { "update" } else { "" }
    
    # install or upgrade visual studio
    vs_professional.exe $updatePrefix --passive --norestart --wait --productkey $productKey --noWeb $selectedWorkloads
    

    解决方法 #2 - 如果未连接到互联网,则仅通过 --noUpdateInstaller

    注意:这将允许 vs_installer.exe 自行更新,但仅使用您离线布局位置的 vsix 包和二进制文件。

    (用于将 VS 部署到主机的示例 PowerShell 脚本,注意:从 UNC 共享调用 vs_professional.exe!)

    hasInternetConnection = try {
      $request = [System.Net.WebRequest]::Create( "http://microsoft.com" )
      $response = $request.GetResponse()
      $response.StatusCode -eq 200
    }
    catch {
      $false
    }
    
    # use '--noUpdateInstaller' iff we are not connected to the internet!
    $updateInstaller = if ($hasInternetConnection) {
      ""
    }
    else {
      "--noUpdateInstaller"
    }
    
    # only pass "update" if VS is already installed
    $updatePrefix = if (Test-IsVSAlreadyInstalled) { "update" } else { "" }
    
    # install or upgrade visual studio
    vs_professional.exe $updatePrefix --passive --norestart --wait --productkey $productKey --nocache $updateInstaller --noWeb $selectedWorkloads
    

    我正在使用诸如解决方法 #2 中描述的脚本,该脚本包含在 Chocolatey 包中,并且目前取得了不错的效果。

    【讨论】:

      【解决方案2】:

      调用 vs_Professional.exe update --wait --norestart --noweb --noUpdateInstaller ... 调用后很快失败,退出代码为“1”。

      其实,每次更新vs,都必须先更新vs_installer程序。正如您所描述的,您使用vs_Professional.exe update --wait --norestart --noweb --noUpdateInstaller,这意味着您正在更新 vs_installer 程序。 Hint from here.

      有没有办法真正强制--noUpdateInstaller,可以Visual 在更新 Visual Studio 之前,还要离线更新安装程序吗?

      --noUpdateInstaller 表示它将阻止更新vs_installer.exe。如果您执行更新,它将返回一个非零退出代码。所以你不能在更新中使用--noUpdateInstaller

      1)如果你想在你的代理上安装旧的VS离线包,你应该使用这个命令来安装它:(断开互联网)

      C:\Layout\vs_Professional.exe --wait --norestart --noweb --quiet --noUpdateInstaller
      

      2)如果你想将vs离线包更新到最新版本,你应该试试这个:

      在服务器上,找到之前创建离线安装包的程序,用这个命令更新:

      vs_Professional.exe --quiet --update
      

      然后运行这个覆盖旧的 Layout 文件夹:

      vs_Professional.exe --layout c:\xxx(the previous offline packages and overwrite the latest updates to this package)
      

      或者直接运行第二条命令也会将离线包更新到最新版本。

      希望对你有帮助。

      【讨论】:

      • 实际上我想更新现有客户端或安装到新客户端。如果没有可用的 vs_isntaller 更新,我提供的命令可以正常工作,但一旦可以在线找到新版本的 vs_installer 就会失败。 - 始终适用于没有互联网连接的主机(升级和初始安装方案。)
      • 您提供的资源声明如下:首先,更新 V​​isual Studio 安装程序:vs_enterprise.exe --quiet --update 然后,更新 V​​isual Studio 应用程序本身:vs_enterprise.exe update --installPath" C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet --wait --norestart 所以实际上 'vs_enterprise update' 似乎是升级 VS 的正确命令(它确实按我期望的方式工作根据本文档)
      • 既然您有解决问题的办法,我建议您可以添加一个答案,然后标记您的答案,以便帮助其他社区成员搜索和处理类似问题。
      • 我在公司代理后面。这对我有用(在将安装移动到短路径 d:\vs 之后):vs_enterprise.exe --quiet --update 然后vs_enterprise.exe update --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet --wait --norestart --noweb --force
      猜你喜欢
      • 2020-01-18
      • 1970-01-01
      • 2021-01-07
      • 2020-05-06
      • 1970-01-01
      • 2021-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多