jberezanski / ChocolateyPackages

Chocolatey packages maintained by me
MIT License
86 stars 52 forks source link

visualstudio2019buildtools Chocolatey Failures #78

Closed Condoamanti closed 4 years ago

Condoamanti commented 4 years ago

Currently getting the following error when attempting to install. Any recommendation in relation to troubleshooting this?

Screenshot: https://imgur.com/a/hUo60eb

validating that the --package-parameters dont work correctly, when running with chocolatey. If i run native from the executable [vs_BuildTools.exe --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools;includeRecommended;includeOptional --add Microsoft.VisualStudio.Workload.MSBuildTools;includeRecommended;includeOptional --add Microsoft.VisualStudio.Workload.NetCoreBuildTools;includeRecommended;includeOptional --add Microsoft.VisualStudio.Workload.WebBuildTools;includeRecommended;includeOptional --passive --norestart] it works fine.

Chocolatey Version: 0.10.15 Command: choco install visualstudio2019buildtools --package-parameters "--allWorkloads --includeRecommended --includeOptional --quiet"

dvirtz commented 4 years ago

I have a similar problem. Trying to install visualstudio2019buildtools inside a docker I get:

visualstudio2019buildtools has been installed.
  visualstudio2019buildtools may be able to be automatically uninstalled.
 The install of visualstudio2019buildtools was successful.
  Software installed to '"C:\Program Files (x86)\Microsoft Visual Studio\Installer"'

Chocolatey installed 9/9 packages. 
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Installed:
 - kb2919355 v1.0.20160915
 - kb2999226 v1.0.20181019
 - dotnetfx v4.8.0.20190930
 - chocolatey-visualstudio.extension v1.8.1
 - visualstudio2019buildtools v16.3.2.0
 - kb2919442 v1.0.20160915
 - visualstudio-installer v2.0.1
 - chocolatey-dotnetfx.extension v1.0.1
 - chocolatey-windowsupdate.extension v1.0.4

Packages requiring reboot:
 - dotnetfx (exit code 3010)

The recent package changes indicate a reboot is necessary.
 Please reboot at your earliest convenience.
The command 'powershell.exe -ExecutionPolicy Bypass -Command choco install --no-progress --yes visualstudio2019buildtools --version=16.3.2.0 --ignore-checksums' returned a non-zero code: 1
jberezanski commented 4 years ago

@condoamanti the linked image does not open for me. Could you please copy and paste the text from the console window?

@dvirtz That looks like a successful installation, what is the problem?

dvirtz commented 4 years ago

The command 'powershell.exe -ExecutionPolicy Bypass -Command choco install --no-progress --yes visualstudio2019buildtools --version=16.3.2.0 --ignore-checksums' returned a non-zero code: 1

dvirtz commented 4 years ago

If I ignore the exit code and try to install vctools with

choco install --no-progress --yes visualstudio2019-workload-vctools --version=1.0.0

I get

ERROR: Running ["C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" --includeRecommended --norestart --quiet --add Microsoft.VisualStudio.Workload.VCTools] was not successful. Exit code was '1'. See log for possible error messages.                                                 1,6.2)'.
  visualstudio2019-workload-vctools may be able to be automatically uninstalled.                                                                                                                   ded --norestart --quiet --add Microsoft.VisualStudio.Workload.VCTools] was not successful. Exit cod
The install of visualstudio2019-workload-vctools was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\visualstudio2019-workload-vctools\tools\ChocolateyInstall.ps1'.
 See log for details.

Chocolatey installed 3/4 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

chocolatey.log can be found at https://gist.github.com/dvirtz/c97339d8e5477febaf9bc73bf508a52a

inorton commented 4 years ago

I got a little futher by instaling dotnetfx first but I still get a failure after

inorton commented 4 years ago

Actually, my error log is exactly the same as the one in the gist posted by @dvirtz

The part that drew my attention is:

2019-11-06 22:30:24,802 648 [DEBUG] - Command ["C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" --includeRecommended --norestart --quiet --add Microsoft.VisualStudio.Workload.VCTools] exited with '1'.
2019-11-06 22:30:24,880 648 [ERROR] - ERROR: Running ["C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" --includeRecommended --norestart --quiet --add Microsoft.VisualStudio.Workload.VCTools] was not successful. Exit code was '1'. See log for possible error messages.
2019-11-06 22:30:24,880 648 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\visualstudio2019-workload-vctools\tools\ChocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '1'.
2019-11-06 22:30:24,880 648 [DEBUG] - Calling command ['"C:\Windows\System32\shutdown.exe" /a']
2019-11-06 22:30:24,943 648 [DEBUG] - Command ['"C:\Windows\System32\shutdown.exe" /a'] exited with '1116'
2019-11-06 22:30:24,974 648 [INFO ] -   visualstudio2019-workload-vctools may be able to be automatically uninstalled.

Which is the install trying to abort a pending shutdown (but there are no pending shutdowns)

burfo commented 4 years ago

I'm experiencing the same issue as @Condoamanti and @inorton .

This is on Windows Server 2016 Core. .NET Framework 4.8 Developer Pack is installed. Chocolatey version 0.10.15

choco install visualstudio2019buildtools --package-parameters "--allWorkloads --includeRecommended --includeOptional --quiet" -y --debug --verbose

Command ["C:\Users\user\AppData\Local\Temp\chocolatey\visualstudio2019buildtools\16.3.8.0\vs_BuildTools.exe" --norestart --allWorkloads --includeRecommended --wait --quiet --includeOptional] exited with '1'.
VERBOSE: No ISO to dismount
ERROR: Running ["C:\Users\user\AppData\Local\Temp\chocolatey\visualstudio2019buildtools\16.3.8.0\vs_BuildTools.exe" --norestart --allWorkloads --includeRecommended --wait --quiet --includeOptional] was not successful. Exit code was '1'. See log for possible
 error messages.
 at Start-VSChocolateyProcessAsAdmin, C:\ProgramData\chocolatey\extensions\chocolatey-visualstudio\Start-VSChocolateyProcessAsAdmin.ps1: line 130
at Start-VSServicingOperation, C:\ProgramData\chocolatey\extensions\chocolatey-visualstudio\Start-VSServicingOperation.ps1: line 38
at Install-VSChocolateyInstallPackage, C:\ProgramData\chocolatey\extensions\chocolatey-visualstudio\Install-VSChocolateyInstallPackage.ps1: line 25
at Install-VSChocolateyPackage, C:\ProgramData\chocolatey\extensions\chocolatey-visualstudio\Install-VSChocolateyPackage.ps1: line 44
at Install-VisualStudio, C:\ProgramData\chocolatey\extensions\chocolatey-visualstudio\Install-VisualStudio.ps1: line 174
at <ScriptBlock>, C:\ProgramData\chocolatey\lib\visualstudio2019buildtools\tools\ChocolateyInstall.ps1: line 1
at <ScriptBlock>, C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1: line 49
at <ScriptBlock>, <No file>: line 1
Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\Prog
ramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\visualstudio2019buildtools\tools\ChocolateyInstall.ps1' -installArguments '' -packageParameters '--allWorkloads --includeRecommended --includeOptional --quie
t''] exited with '1'.
Calling command ['"C:\windows\System32\shutdown.exe" /a']
Command ['"C:\windows\System32\shutdown.exe" /a'] exited with '1116'

For now I've done this, successfully:

choco install visualstudio2019buildtools -y
choco install visualstudio2019-workload-manageddesktopbuildtools -y
choco install visualstudio2019-workload-nodebuildtools -y
choco install visualstudio2019-workload-netcorebuildtools -y
jberezanski commented 4 years ago

@inorton

Which is the install trying to abort a pending shutdown (but there are no pending shutdowns)

AFAIK choco.exe always invokes shutdown /a, probably just in case the package author forgot to pass the appropriate "no auto reboot" switch to a native installer. I'm guessing the exit code 1116 is shutdown.exe complaining there is no shutdown pending (indeed, the docs confirm that).

jberezanski commented 4 years ago

Upgrading the .NET Framework nearly always requires a reboot; until it is done, programs depending on .NET (such as the Visual Studio installer) may behave erratically or simply fail to run. Having said that, in my tests the Visual Studio installation usually succeeded even if .NET was upgraded as part of it, but your mileage may vary. That is why the package description recommends upgrading .NET and rebooting first.

As for Docker, I believe the Windows docker images do not support reboots, so your only option is to start with a base image which already has the latest .NET included.

jberezanski commented 4 years ago

@dvirtz I've analyzed the log file you posted and here are my findings:

  1. Installation of visualstudio2019buildtools

Interesting log lines:

2019-11-06 21:19:56,191 1928 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" install --no-progress --yes visualstudio2019buildtools --version=16.3.2.0

2019-11-06 21:20:26,799 1928 [INFO ] - [NuGet] Installing 'dotnetfx 4.8.0.20190930'.

2019-11-06 21:26:42,960 1928 [WARN ] - WARNING: Microsoft .NET Framework 4.8 has been installed, but a reboot is required to finalize the installation. Until the computer is rebooted, dependent packages may fail to install or function properly.

2019-11-06 21:30:54,792 1928 [DEBUG] - Command ["C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\visualstudio2019buildtools\16.3.2.0\vs_BuildTools.exe" --quiet --norestart --wait] exited with '0'.

2019-11-06 21:30:54,808 1928 [DEBUG] - Setting Env:ChocolateyExitCode to '0'

2019-11-06 21:30:55,058 1928 [DEBUG] - Exiting with 3010

We can see that

Earlier, you posted:

The command 'powershell.exe -ExecutionPolicy Bypass -Command choco install --no-progress --yes visualstudio2019buildtools --version=16.3.2.0 --ignore-checksums' returned a non-zero code: 1

which suggests that code 3010 returned by choco.exe got translated to 1 by powershell.exe. This, actually, is known PowerShell behavior. Taking advice from the PowerShell architect, in order to have powershell return the real choco.exe exit code, you can add a exit $LastExitCode to the command passed to PowerShell. You would need to wrap it in a scriptblock, like this: `powershell.exe -ExecutionPolicy Bypass -Command "& { choco install --no-progress --yes visualstudio2019buildtools --version=16.3.2.0 --ignore-checksums; exit $LastExitCode }".

Also, the message suggests that whatever tool you use to invoke powershell.exe might treat all nonzero exit codes as errors. If that is the case and the tool cannot be configured to accept 3010 as success, you would need to add conditional logic after choco.exe invocation to set the exit code to 0 if choco returns 3010.

  1. Installation of visualstudio2019-workload-vctools
2019-11-06 22:30:24,880 648 [ERROR] - ERROR: Running ["C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" --includeRecommended --norestart --quiet --add Microsoft.VisualStudio.Workload.VCTools] was not successful. Exit code was '1'. See log for possible error messages.

In this case code 1 comes from the Visual Studio Installer, which means the installation has truly failed. In order to determine the cause you would need to review the numerous logs the VS install process writes to $Env:TEMP\chocolatey; they are named dd_*.log, for example "dd_client20191124024038.log". The cause of the failure should be described in one of those files, probably in one of the last modified ones. If you need help in interpreting them, I can take a look - please provide all of the `dd*.log` files (I believe it is possible to attach a zip archive to a gist).

dvirtz commented 4 years ago

Thanks @jberezanski. After making it return 0 on error code 3010 the vctools installation succeeds.

inorton commented 4 years ago

@dvirtz what did you change? do you have a patch?

dvirtz commented 4 years ago

@inorton I'm using Install.cmd as described here:

COPY Install.cmd C:\TEMP\

RUN C:\TEMP\Install.cmd choco install --no-progress --yes visualstudio2019buildtools --version=16.3.2.0
RUN C:\TEMP\Install.cmd choco install --no-progress --yes visualstudio2019-workload-vctools --version=1.0.0
RUN C:\TEMP\Install.cmd choco install --no-progress --yes --execution-timeout=0 visualstudio2019-workload-manageddesktop --version=1.0.1
inorton commented 4 years ago

@dvirtz ah great. I actually have a python script doing that job so i will try accordingly