I'm trying to programatically turn on (install) the .Net 2.0 Framework Windows feature. (B/c Windows 7 and above doesn't let you install .net manually and my customers are never going to be able to enable that from the control panel.). Windows 7 includes .net 2.0 but Windows 8 does not (at least in my testing)
I think the answer is:
dism.exe /online /enable-feature /featurename:NetFX3
based on many posts including this one.
- Is the [most] correct way to install the .net 3.0 framework?
- Is there any way to install just the .net 2.0 framework?
What I've tried;
- using the /get features of dism.exe to get all features it can turn on. The only .net listed was netfx3
You can also trigger the Windows Features on Demand User Experiance applet directly without having to start a .Net executable or the setup. This is supported only only Windows 8 (per this chart)
fondue.exe /enable-feature:NetFx3
The short answer: It is not your job as an ISV to manage installation of the .net framework, call the .Net Framework installation bootstrapper and be done with it. System admins may wish to deploy the software in different ways, make sure you are not limiting yourself by making assumptions.
The long answer: Use the deployment guide to determine how to package your application with the .net Framework.
Update regarding DISM:
I didn't mean to suggest that DISM is going to dissappear, only that references to DISM are being replaced with references to powershell and that DISM is a purely administrative tool. For example, compare the MSDN documentation on Installation of Windows Features for Windows Server 2012 which hilights Install-WindowsFeature for administrative installation of features and only mentions DISM briefly to the equivelent documentation for 2008 R2.
However, I maintain that actions like adding and removing roles and features should not be performed silently as the result of an application installation. Per the deployment guide, the reccomended installation method for chaining the .Net Framework is to call the bootstrapper and leave the rest to it. See here for exact arguments.
The bootstrapper, which would normally install the .net framework in a lower version of Windows, is shimmed and replaced by the dialog listed below - as long as there are no other deployment concerns (media, permissions, group policy, etc...) The feature is installed and everyone is happy. If there are deployment concerns, the user is directed to the Server Management tool, where it can be enabled manually.
Beyond the formal guidance for installation of the .Net Framework, on demand installation is referenced as the preferred method for maintaning compatibility in the below documents:
- New features in .Net 4.5 (Slide 8)
"Preferred: Your setup tries to install 3.5 MSI ... shim installs correct version..."
- Windows 8 and .Net Framework 3.5
"You attempt to install .Net 2.0, 3.0, or 3.5 using a redistributable package available for download from Microsoft... an application shim in Windows 8 intercepts the attempt and invokes the installation of the new .Net 3.5 feature. Once triggered, the installation should proceed as if it was initiated from the UI, DISM, or Powershell."
- Installing the .NET Framework 3.5 on Windows 8
"To run applications that require the .NET Framework 3.5 on Windows 8, you must enable version 3.5 on your computer. There are two ways you can do this: by installing or running an application that requires the .NET Framework 3.5 (that is, by installing the .NET Framework 3.5 on demand), or by enabling the .NET Framework 3.5 in Control Panel."