gpt4 book ai didi

visual-studio - Visual Studio 2019 离线布局更新忽略 '--noUpdateInstaller'

转载 作者:行者123 更新时间:2023-12-05 06:15:59 24 4
gpt4 key购买 nike

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

目前,我们不能再使用离线布局来安装本地缓存版本的 Visual Studio,因为连接到互联网的计算机需要在安装任何东西之前更新“Visual Studio Installer”。

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.

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

有没有办法真正强制--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

最佳答案

不幸的是,--noUpdateInstaller 开关非常具有误导性,并没有完全按照它的名称建议进行操作。

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

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

If you want to install from an offline source on a non-internetconnected computer, specify both the --noWeb and --noUpdateInstalleroptions. The former prevents downloading updated workloads,components, and so on. The latter prevents the installer fromself-updating from the web.

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


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

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

# 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 脚本,注意:vs_professional.exe 是从 UNC 共享调用的!)

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

我正在使用包装在 Chocolatey Package 中的变通办法 #2 中描述的脚本,到目前为止取得了良好的效果。

关于visual-studio - Visual Studio 2019 离线布局更新忽略 '--noUpdateInstaller',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62259223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com