Cannot install .NET 3.5 on Windows Server 2012 R2 with Chef Test Kitchen

0

I could not find a way to install .NET 3.5 with Chef Test Kitchen on Windows Server 2012 R2.

I can install the framework from the command line with

C:\Windows\system32\dism.exe /online /enable-feature /featurename:NetFx3 /norestart /All /source:"C:\Users\admin\AppData\Local\Temp\dotnetfx35.exe"

or from the PowerShell prompt with

Install-WindowsFeature –name NET-Framework-Core –source "C:\Users\admin\AppData\Local\Temp\dotnetfx35.exe"

but if I execute any of the following in chef I get the same error:

Deployment Image Servicing and Management tool

Version: 6.3.9600.17031

Image Version: 6.3.9600.17031

Enabling feature(s)

Error: 0x800f0906

The source files could not be downloaded.

Use the "source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink....

I have copied the dotnetfx35.exe to the user's temp directory at C:\Users\admin\AppData\Local\Temp\dotnetfx35.exe

chef --version

Chef Development Kit Version: 0.15.16

chef-client version: 12.11.18

delivery version: master (444effdf9c81908795e88157f01cd667a6c43b5f)

berks version: 4.3.5 kitchen version: 1.7.3

The resources I have tried so far:

Using Chocolatey:

chocolatey_package 'dotnet3.5' do
  options "--allow-empty-checksums --ignore-package-exit-codes"
end

Execute:

  execute 'install_dot_net_3-5' do
    command "C:\\Windows\\system32\\dism.exe /online /enable-feature /featurename:NetFx3 /norestart /All /source:\"C:\\Users\\admin\\AppData\\Local\\Temp\\dotnetfx35.exe\""
    timeout 9999
  end

Batch:

  batch 'install_dot_net_3-5' do
    code <<-EOH
      C:\\Windows\\system32\\dism.exe /online /enable-feature /featurename:NetFx3 /norestart /All /source:"C:\\Users\\admin\\AppData\\Local\\Temp\\dotnetfx35.exe"
    EOH
    cwd "#{ENV['TEMP']}"
    timeout 9999
  end

Powershell script:

  powershell_script 'install_dot_net_3-5' do
    code <<-EOH
      Install-WindowsFeature –name NET-Framework-Core –source "C:\\Users\\admin\\AppData\\Local\\Temp\\dotnetfx35.exe"
    EOH
  end
.net-3.5
chef-infra
asked on Stack Overflow Sep 13, 2016 by Laszlo Pinter • edited Sep 13, 2016 by Laszlo Pinter

1 Answer

1

Many thanks to Matt Wrock from Chef who sent me the answer:

If you are trying to install .net 3.5 via test kitchen, use the elevated winrm transport. This will allow .net 3.5 to be accessed via windows update without the need for pointing at a source file. Remove the source argument from your dism command and add this to your .kitchen.yml:

transport:
  name: winrm
  elevated: true

After adding elevated: true to the .kitchen.yml file, I have successfully installed .NET 3.5 on Windows Server 2012 R2 in Test Kitchen with the following code in the recipe. The same recipe works in Chef Client on the production box.

  powershell_script 'install_dot_net_3-5' do
    code <<-EOH
      Install-WindowsFeature -name NET-Framework-Core
    EOH
  end
answered on Stack Overflow Sep 14, 2016 by Laszlo Pinter

User contributions licensed under CC BY-SA 3.0