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.

Selecting Features in Add Roles and Features Wizard
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.
<code>PS D:\> dism /Mount-Wim /wimfile:d:\sources\install.wim /index:4 /mountdir:d:\temp\wimmount</code> Deployment Image Servicing and Management tool<br>
Version: 6.2.9200.16384<br><br>
Mounting image<br>
The operation completed successfully.<br><br>
PS D:\> <strong>dism /image:d:\temp\wimmount /enable-feature /featurename:NetFx3 /All /Source:c:\windows\winsxs</strong><br><br>
Deployment Image Servicing and Management tool<br>
Version: 6.2.9200.16384<br><br>
Image Version: 6.2.9200.16384<br><br>
Enabling feature(s)<br>
The operation completed successfully.<br><pre>PS D:\> dism /image:d:\temp\wimmount /disable-feature /featurename:NetFx3</pre>
<br>
Deployment Image Servicing and Management tool<br>
Version: 6.2.9200.16384<br><br>
Image Version: 6.2.9200.16384<br><br>
Disabling feature(s)<br>
The operation completed successfully.
<code>PS D:\> dism /Unmount-Wim /mountdir:d:\temp\wimmount /commit</code> Deployment Image Servicing and Management tool<br>
Version: 6.2.9200.16384<br><br>
Image File : d:\sources\install.wim<br>
Image Index : 4<br>
Saving image<br>
The operation completed successfully.



