目前,我们无法再使用离线布局来安装本地缓存版本的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.
我们在调用Visual Studio Installer时已经使用了
--noweb
和--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
vs_enterprise.exe --quiet --update
,然后vs_enterprise.exe update --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet --wait --norestart --noweb --force
。 - Anton Krouglov