Add the .NET Framework 3.5 to a VHD or WIM File
How to add the .NET Framework 3.5 to your VHD or WIM file to make it locally available should you want to enable it in the future.
March 1, 2013
Q: How do I add the .NET Framework 3.5 to my VHD or WIM file so it's locally available should I want to enable it in the future?
A: As you might know, in Windows Server 2012 and Windows 8 the .NET Framework 3.5 isn't locally available for installations. This is because of its size and because Windows 2012/Windows 8 have the new .NET Framework 4.0, so providing both used too much disk space.Instead, when .NET Framework 3.5 is enabled as a feature, it's either downloaded from Windows Update or you can specify a location such as a folder or WIM file as the source.
The easiest way to add the .NET Framework 3.5 to a (virtual hard disk) VHD file (that's perhaps a template for the creation of future virtual machines--VMs) is to just add the .NET Framework 3.5 feature, which will cause the files to be copied to the VHD; then disable the .NET 3.5 feature (which will leave the files locally available).
Run the Add Roles and Features Wizard as usual, but select the option to select a VHD from the Server Selection page, pick your VHD, then continue. After .NET Framework 3.5 is added, rerun the wizard in removal mode, select the same VHD, and remove the feature.
The screenshots below show the entire process. This could also be done with Windows PowerShell by using the Install-WindowsFeature and Remove-WindowsFeature cmdlets.
Add Roles and Features Wizard
Selecting Features in Add Roles and Features Wizard
Installation Progress
Removing .NET Framework
For a WIM file, using DISM is the best choice. In the example below, I mount the WIM file, then add .NET Framework 3.5 with the source being my local server's side-by-side assembly (which already has .NET Framework 3.5 installed using Features on Demand). Then I remove it straight away (which leaves the files in the WIM). Once it's removed, dismount the WIM by using the commit option.
PS D:> dism /Mount-Wim /wimfile:d:sourcesinstall.wim /index:4 /mountdir:d:tempwimmount
Deployment Image Servicing and Management tool
Version: 6.2.9200.16384
Mounting image
The operation completed successfully.
PS D:> dism /image:d:tempwimmount /enable-feature /featurename:NetFx3 /All /Source:c:windowswinsxs
Deployment Image Servicing and Management tool
Version: 6.2.9200.16384
Image Version: 6.2.9200.16384
Enabling feature(s)
The operation completed successfully.
PS D:> dism /image:d:tempwimmount /disable-feature /featurename:NetFx3
Deployment Image Servicing and Management tool
Version: 6.2.9200.16384
Image Version: 6.2.9200.16384
Disabling feature(s)
The operation completed successfully.
PS D:> dism /Unmount-Wim /mountdir:d:tempwimmount /commit
Deployment Image Servicing and Management tool
Version: 6.2.9200.16384
Image File : d:sourcesinstall.wim
Image Index : 4
Saving image
Unmounting image
The operation completed successfully.
About the Author
You May Also Like