Unable to install .NET Framework 4.6 on Windows Server 2012 R2 Core

Both .NET 4.6 and 4.6.1 installers attempt to use GUI functionality not available on Server Core and crash. This happens even in passive mode. Fortunately, completely quiet installation works:

NDP46-KB3045557-x86-x64-AllOS-ENU.exe /q

or

NDP461-KB3102436-x86-x64-AllOS-ENU.exe /q

(add /norestart if you do not want the server to reboot automatically)


My solution is as follows:

  1. Manually extract all files in the [Offline installer|https://www.microsoft.com/en-us/download/details.aspx?id=48137] using 7zip.
  2. Run dism.exe to add the appropriate package for Win Server 2012 Core 64-Bit.

Here's the script I used. NOTE the script installs the appropriate package for Windows Server 2012 64-Bit and has not been tested on Win RT or 32-bit systems:

# Installs the .Net 4.6 onto Windows Server 2012 Core instances.
# Running the exe causes an error due to the User-Interfaces-Infra feature not being installed
$ErrorAction = "Stop"

# Download URL has been pulled from the Chocolatey DotNet4.6 install script
$downloadUrl = "http://download.microsoft.com/download/C/3/A/C3A5200B-D33C-47E9-9D70-2F7C65DAAD94/NDP46-KB3045557-x86-x64-AllOS-ENU.exe"
$fileDestination = "c:\dotnet46.exe"
$extractDir = "c:\dotnet46"

(New-Object net.webclient).DownloadFile($downloadUrl, $fileDestination)

& 7z.exe e -y -o"$extractDir" "$fileDestination"

dism.exe /online /norestart /add-package /PackagePath:$extractDir\x64-Windows8.1-KB3045563-x64.cab