Cannot install .NET Framework 3.5 features on Windows Server 2012
On a default installation of Windows Server 2012 sometimes you experience problems with the .NET Framework 3.5 features while trying to enable it.
It fails if you try to install it using the Add Roles and Features Wizard, using Powershell or dism.
The same happens during an SQL Server installation with the following error message:
The following error has occurred:
Error while enabling Windows feature: NetFx3, Error Code: -2146498298, Please try enabling Windows feature: NetFx3 from Windows management tools and then run setup again.
On the Add Roles and Features Wizard’s Confirmation page spot the difference: On the top of the page there is an exclamation mark and a short message about missing source files. This simply means that you selected one or more roles and features which files are not available for the operating system at the moment. To amend this select the Sepcify an alternate source path on the bottom of the page.
On this new window enter the path to your Windows Server 2012 sources/sxs folder. The WIM file won’t work, you need the previously mentioned folder!
That’s all using the GUI, sorted.
To do the same thing using Powershell type the following command:
Install-WindowsFeature NET-Framework-Core -Source D:\sources\sxs
Where NET-Framework-Core is the feature’s name, and D:\sources\sxs is a folder on the Windows Server 2012 media.
You can do the same thing from a command prompt, using dism.exe:
dism.exe /online /enable-feature /featurename:netfx3 /all /source:D:\sources\sxs
Online swith simply tells dism to do the task on the running system, the feature’s name with dism is netfx3 (remember the SQL server’s error message? It mentioned the same feature name.) and the last part is the alternate path.
After a few solutions to this problem let!s take a look at the reasons behind this error.
If you open a Powershell window and query the roles and features (Get-WindowsFeature) take a look at .NET Framework 3.5.
In the last column the Install state is different, it says Removed.
- Available means that you can install the feature and the source files are on the machine and the OS can use them
- Installed means that the role or feature is already enabled and in use
- Removed means that you can install the feature but the source files for that are not available for this OS
This is the main difference from any other role or feature and this is the reason the installation fails, the source files are not available. Well, this would not be a problem because Windows can also download them from the Internet! So if you never experienced this but installed this feature or SQL multiple times without any issues, the reason is that your machine simply downloaded the files from the Internet. But in some scenarios this is not possible for various reasons.
By the way you can uninstall any source files like this for any role or feature and it is called Features on demand, read more about this topic here: Roles, features and the WinSxS folder in Windows Server 2012
With features on demand later, most of the time you specify the install.wim file, but this won’t work with .NET Framework 3.5, because by default the sources are not in there. Does not matter if you specify it with the source parameter, copy the files or mount the wim, the files are not there. That’s why any solution recommending this is wrong.
But you can always prepare your own wim file or image with .NET Framework source files already in there, use dism.exe for this task.
.NET Framework 3.5 feature installation files are not available by default in a Windows Server 2012 system (neither from the install.wim file)
Windows tries to download the files from the Internet. If you want to avoid it or your server cannot access it specify an alternate source path on the Confirmation page of the wizard or use the source parameter of dism.exe or Install-WindowsFeature powershell commandlet.
The files are not in the install.wim file, but you can create your own with dism for example.