Установка MSBuildTools 2017 (vs_buildtools) с помощью Chef

Мне было интересно, удалось ли кому-нибудь выяснить, как установить MSBuildTools 2017 с Chef 11 (извините, я отстал).

Установщик: https://www.visualstudio.com/downloads/ (в разделе Инструменты сборки для VS2017)

Я пробовал два разных способа, и оба, кажется, просто запустить исполняемый файл и затем выйти.

Я пробовал использовать оба параметра --quiet и --passive в качестве переключателей командной строки, и оба, похоже, действуют одинаково.

Я могу запустить это на сервере, и он установит его, так что я думаю, что мое действие командной строки правильно:

vs_buildtools__540411490.1488812665.exe --passive --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools

Ресурс выполнения:

unless ::File.directory?('C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools')
  remote_file vs_buildtools_2017_msbuild_installer do
    source 'http://myartifactory.localdomain.com/artifactory/chef/Installers/VisualStudioBuildTools/2017/vs_buildtools__540411490.1488812665.exe'
    action :create
  end

  execute 'Install-VS-BuildTools-2017' do
    command "#{vs_buildtools_2017_msbuild_installer} --quiet --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools"
    action :run
  end
end

Кажется, это работает успешно, но в конечном итоге не устанавливает то, что мне нужно.

execute[Install-VS-BuildTools-2017] action run[2017-08-09T11:42:05-04:00] INFO: Processing execute[Install-VS-BuildTools-2017] action run (hps-windows::build_server line 252)
[2017-08-09T11:42:06-04:00] INFO: execute[Install-VS-BuildTools-2017] ran successfully

- execute c:/windows/temp/vs_buildtools__540411490.1488812665.exe --quiet --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools

[2017-08-09T11:42:06-04:00] INFO: Chef Run complete in 65.787128 seconds

Ресурс windows_package:

windows_package 'Always Run unless the guard says otherwise' do
  source 'http://myartifactory.localdomain.com/artifactory/chef/Installers/VisualStudioBuildTools/2017/vs_buildtools__540411490.1488812665.exe'
  options '--quiet --wait --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools'
  installer_type :custom
  action :install
  not_if { ::File.directory?('C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools') } 
end

Выход для этого:

[2017-08-09T12:26:48-04:00] INFO: remote_file[C:\cygwin\home\Administrator\.chef\local-mode-cache\cache/vs_buildtools__540411490.1488812665.exe] updated file contents C:\cygwin\home\Administrator\.chef\local-mode-cache\cache/vs_buildtools__540411490.1488812665.exe

- update content in file C:\cygwin\home\Administrator\.chef\local-mode-cache\cache/vs_buildtools__540411490.1488812665.exe from e89957 to 68a678
    (new content is binary, diff output suppressed)

[2017-08-09T12:26:48-04:00] INFO: Starting installation...this could take awhile.


[2017-08-09T12:26:49-04:00] INFO: Chef Run complete in 65.276391 seconds

Немного дополнительной информации, если я использую команду ожидания, она выдаст ошибку -200 и сделает это:

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '-200'
---- Begin output of c:/windows/temp/vs_buildtools__540411490.1488812665.exe --quiet --wait --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools ----
STDOUT: Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1028\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\2052\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1055\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1046\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1042\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1036\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1029\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\3082\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1040\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1031\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1045\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1041\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1049\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\HelpFile\1033\help.html...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\vs_setup_bootstrapper.exe...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\Microsoft.Diagnostics.Tracing.EventSource.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\Microsoft.VisualStudio.RemoteControl.Net35.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Download.Net35.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\Microsoft.VisualStudio.Telemetry.Net35.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\Microsoft.VisualStudio.Utilities.Internal.Net35.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\Newtonsoft.Json.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\System.Threading.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\zh-Hans\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\cs\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\de\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\es\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\fr\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\it\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\zh-Hant\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\ja\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\ko\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\pl\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\pt-BR\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\ru\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\tr\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\vs_setup_bootstrapper.config...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\vs_setup_bootstrapper.exe.config...
Preparing: C:\Users\Administrator\f3ce1450c1e0b7515b5ec5ed\vs_bootstrapper_d15\vs_setup_bootstrapper.json...
STDERR:
---- End output of c:/windows/temp/vs_buildtools__540411490.1488812665.exe --quiet --wait --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools ---- 

Это заставляет меня поверить, что, возможно, он запускает эту команду, распаковывает все, а затем ожидает еще один вызов с использованием, возможно, того же самого окна командной строки (которого, вероятно, не будет в стране шеф-повара), и запускает следующую команду.

-------------- Обновление от 28.08.2017 ----------------
Я переключился на использование этого вместо этого, и это также не сработало: vs_buildtools_2017_msbuild_install_zip = 'c:/windows/temp/vs_buildtools_2017.zip' vs_buildtools_2017_msbuild_install_location = 'c:/windows/temp/vs_buildtools_bu_s__t__in_S_M_S_N_S_B_S_S_B_S_S_S_S_S_B_7_7 / vs_buildtools_2017 / Установщик ' vs_buildtools_2017_msbuild_installer ='c:/windows/temp/vs_buildtools_2017/Installer/vs_installershell.exe '

    if ::File.directory?('C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools')
      file vs_buildtools_2017_msbuild_install_zip do
        action :delete
      end

      directory vs_buildtools_2017_msbuild_install_location do
        action :delete
      end
    else
      remote_file vs_buildtools_2017_msbuild_install_zip do
        source 'http://myartifactory.localdomain.com/artifactory/chef/Installers/VisualStudioBuildTools/2017/vs_buildtools_2017.zip'
        action :create
      end

      # Unzip Windows 8.1 SDK
      windows_zipfile vs_buildtools_2017_msbuild_install_location do
        source vs_buildtools_2017_msbuild_install_zip
        action :unzip
        not_if { ::File.directory? vs_buildtools_2017_msbuild_install_location }
      end

      execute 'Install-VS-BuildTools-2017' do
        command "#{vs_buildtools_2017_msbuild_installer} --passive --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools"
        cwd vs_buildtools_2017_msbuild_installer_dir
        action :run
      end
    end

Выход:

[8/25/2017, 15:59:51] === Logging started: 2017/08/25 15:59:51 ===
[8/25/2017, 15:59:51] Executable: C:\windows\temp\vs_buildtools__540411490.1488812665.exe v15.0.26430.16
[8/25/2017, 15:59:51] --- logging level: standard ---
[8/25/2017, 15:59:51] Directory 'C:\Users\Administrator\7d66710b377678a993285658a9e2\' has been selected for file extraction
[8/25/2017, 15:59:51] Extracting files to: C:\Users\Administrator\7d66710b377678a993285658a9e2\
[8/25/2017, 15:59:51] Extraction took 172 milliseconds
[8/25/2017, 15:59:51] Executing extracted package: 'vs_bootstrapper_d15\vs_setup_bootstrapper.exe ' with commandline '  --passive --norestart --add Microsoft.VisualStudio.Workload.MSBuildTools'
[8/25/2017, 15:59:52] The entire Box execution exiting with result code: 0x0
[8/25/2017, 15:59:52] Launched extracted application exiting with result code: 0x0
[8/25/2017, 15:59:52] === Logging stopped: 2017/08/25 15:59:52 ===

-------------- Обновление от 06.09.2017 ----------------
Я включил поддержку Chef, и очевидно, что chef устанавливает или, по крайней мере, использует установочные файлы, расположенные в C:\Program Files\Microsoft Visual Studio\Installer, в то время как обычный установщик использует аналог Program Files (x86).

Спасибо,
Alex

1 ответ

Вот как у меня это заработало.

# Installs msbuild tools 2017
package_checksum = '{MY CHECKSUM}'
package_source = '{URL TO ARTIFACTORY REPO}/vs_buildtools__730419789.1549921800.exe'

msbuild_location = ::File.join('c:',
                               'Program Files (x86)',
                               'Microsoft Visual Studio',
                               '2017',
                               'BuildTools',
                               'MSBuild',
                               '15.0',
                               'Bin',
                               'msbuild.exe')

# Note: Msbuild tools is a pain and a half to update. I currently manually uninstall it before updating because it has a hard time figuring out what it's doing.
command = '--quiet --wait --norestart'\
' --add Microsoft.VisualStudio.Workload.MSBuildTools'\
' --add Microsoft.VisualStudio.Workload.NetCoreBuildTools'
package 'msbuild tools 2017' do
  source package_source
  checksum package_checksum
  installer_type :custom
  action :install
  returns [0, 3010]
  options command
  not_if do
    ::File.exist?(msbuild_location)
  end
end

Обновление - проверить версии драгоценных камней

gem 'winrm', '~> 2.0'
gem 'winrm-fs', '~> 1.0'

Рецепт, используемый для Windows Server 2012r2:

windows_package 'msbuild tools' do
  source 'https://aka.ms/vs/15/release/vs_buildtools.exe'
  installer_type :custom
  action :install
  returns [0, 3010]
  not_if {::File.exist?('c:\\Program Files (x86)\\Microsoft Visual Studio\\2017\BuildTools\\MSBuild\\15.0\\Bin\\msbuild.exe')}
  options '--passive --norestart'
end

Я использовал Chef 12 с опциями '/passive /norestart'

Я изменил варианты на '--passive --norestart' и это сработало.

Другие вопросы по тегам