The AppLife Update Blog
A complete solution for maintaining deployed software on the Windows platform
In Windows 8, the .Net Framework 3.5 is not installed by default, however Windows 8 includes a Feature on Demand (FoD) option for the earlier frameworks.
We can enable this feature during an application update by using the Deployment Image Servicing and Management utility (dism). During an application update, we’ll execute the following command line:
dism /online /enable-feature /featurename:NetFX3 /all /NoRestart /Quiet
We can use a Run Command Line update action to perform the work. We just need to ensure that the update has elevated permissions. If you are already configured for update elevation, either by use of the AppLife Update Windows service or by the UAC, this is already taken care of. If however, your normal updates are not elevated, then you must explicitly set this update to elevate via the UAC when you publish the update.
Configuring the Update
To accomplish the goal, we’ll create an action list and name it Win 8 FX 3. In this action list, we’ll add:
- Run Command Line action
- Restart Operating System action
- Prevent application restart action
Run Command Line
This action will run the dism command. This command requires an operating system restart, so we’ll explicitly command not to restart, and then let the update take care of this using a Restart Operating System action.
Note that this action takes some time to complete.
Restart Operating System
This command will prompt the user that a restart is required.
Prevent Application Restart
If the host application will ordinarily restart after the update completes, we can suppress this knowing that the operating system must be restarted to complete the update. Depending on the host configuration, this action might or might not be necessary.
Conditionally Execute the Action List
We only want to run this action list if the host operating system is Windows 8 and the .Net Framework 3.5 is not already installed. So from the primary action list, we’ll detect the OS version and .Net Framework 3.5 install state, and then run the Win 8 FX 3 action list only when necessary. To detect the OS version, we use a Read Registry Value action to read and assign the OS version to a Shared Property we’ll name WinVersion.
To detect the .Net Framework install state, we’ll inspect another registry key. Note that the dismtool can retrieve information on Windows features using the Get command, however using that approach would require code to parse the command return information.Reading directly from the registry doesn’t require any parsing code.
These shared properties can then be used as a condition to run the Win 8 FX 3 action list.
That completes the configuration of the update. Now all we need to do is ensure that the update will run elevated, if your application isn’t already set up to ensure this. When publishing, we can set this update to use the UAC for permissions elevation.
Ensure Elevation for this Update
The host for this update must be capable of running on the .Net 4.0 framework, as this will be available on Windows 8 out of the box. After running this update, executables that target the .Net 2.0 through 3.5 framework will be able to run on the deployed system.