Lỗi windows server roles and features cannot be automatically installed năm 2024

This article shows how to install and remove Windows Server roles and features by using Server Manager.

Show

Use the following steps to add Windows roles and features:

  1. To open Server Manager, click the Server Manager icon in the taskbar or select Server Manager in the Start Menu.
  2. Click Manage in the upper right portion of the screen and click Add Roles and Features to open a wizard.

    📘

You cannot add roles and features until Server Manager finishes loading. Wait until Server Manager loads before you add roles and features.
  1. On the Before you begin page, click Next to begin. You can skip this page in the future by checking Skip this page by default box.
  2. On the Select installation type page, choose Role-based or feature-based installation and click Next.
  3. On the Server Selection page, choose the server to which you want to add the role or feature. In most cases, this choice is the server you are logged in to. Click Next.
  4. Select all desired roles on the Server Roles page. When you add roles, the wizard prompts you to add prerequisite roles and features, if any. After you have selected the desired roles, click Next.
  5. Select all desired features on the Features page and click Next.
  6. Complete the configuration of the selected roles and features and click Next on each screen.
  7. After you complete the initial configuration of the chosen features, the Confirmation page displays and lists a summary of the changes. Verify the changes before proceeding. If you want the server to restart automatically after installation completes, check the box labeled Restart the destination server automatically if required.
  8. Click Install to add the chosen roles and features.
  9. To open Server Manager, click the Server Manager icon in the taskbar or select Server Manager in the Start Menu.
  10. Click on Manager in the upper right portion of the screen and click Remove Roles and Features to open a wizard.

    📘

You cannot add roles and features until Server Manager finishes loading. Wait until Server Manager loads before you add roles and features.
  1. On the Before you begin page, click Next to begin. You can skip this page in the future by checking Skip this page by default box.
  2. On the Select Destination Server page, choose the server from which you want to remove the role or feature. In most cases, this is the server you are logged in to. Click Next.
  3. Select roles for removal on the Server Roles page. When you remove roles, the wizard prompts you to remove any roles and features that depend on the role you selected for removal. After you have selected the desired roles, click Next.
  4. Select any features for removal on the Features page and click Next.

On the Confirmation page, verify the changes before proceeding. If you want the server to restart automatically after installation completes, check the box labeled Restart the destination server automatically if required.

Although Windows Server roles and features can be automatically installed from the Server Manager, some of those features require source files. For instance, when I’ve tried to install .Net Framework via the Windows Features Control Panel I have received the error message:

The following feature couldn’t be installed: .Net Framework 3.5 (includes .NET 2.0 and 3.0)

A similar error message appeared when I have tried to install .Net Framework 3.5 using the Server Manager: The request to add or remove features on the specified server failed.

Lỗi windows server roles and features cannot be automatically installed năm 2024

To fix this problem, we’ll have to provide source files for the .NET Framework installation. So, open File Explorer and double click the Windows Server ISO image to map the image in Explorer.

Lỗi windows server roles and features cannot be automatically installed năm 2024

Run the .NET Framework installation again and in the Confirmation screen click on the “Specify an alternate source path” link.

Now, browse the mapped ISO image and navigate to X:\Sources\SxS where X: represents the drive letter that was used to map the ISO image. Please note, if you select X:\Sources folder it will not work, you have to choose the SxS folder.

After the source files folder has been selected, you should be able to install .NET Framework 3.5 along with .NET 2.0 and 3.0 without any issues.

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.

Lỗi windows server roles and features cannot be automatically installed năm 2024
.NET Framework 3.5 features installation failure

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.

Lỗi windows server roles and features cannot be automatically installed năm 2024
Error while enabling Windows feature: NetFx3

Solution

GUI

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.

Lỗi windows server roles and features cannot be automatically installed năm 2024
Missing installation source files

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!

Lỗi windows server roles and features cannot be automatically installed năm 2024
Alternate source path

That’s all using the GUI, sorted.

Powershell

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.

Lỗi windows server roles and features cannot be automatically installed năm 2024
Install .NET Framework 3.5 features using Powershell

Command prompt

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.

Lỗi windows server roles and features cannot be automatically installed năm 2024
Install .Net Framework 3.5 with dism.exe

Explanation

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.

Lỗi windows server roles and features cannot be automatically installed năm 2024
Windows roles and features in a Powershell window

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.

Summary

.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.