Product Documentation

For layering in or publishing to Hyper-V

Jan 11, 2018

To create a Platform Layer you:  

  • Prepare a new Platform layer using the Create Platform Layer wizard.
  • Deploy a Packaging Machine in your environment.
  • Configure the settings for Hyper-V.
  • Verify the layer.
  • Finalize the layer.

Prerequisites

When creating a Platform layer for Hyper-V, be sure to be prepared with the following information:

  • Hyper-V settings

If the operating system image you used to create your OS layer originated in Hyper-V, you do not need a Hyper-V Platform layer, because the Hyper-V settings are already included in your OS layer. There are no additional prerequisites when selecting Hyper-V as the hypervisor in your Platform Layer.  

If the operating system image you used to create your OS layer originated on a different hypervisor, you should set the Hyper-V settings in the Platform layer. The purpose of these settings is to ensure that applications install and run flawlessly in Hyper-V.  

  • KMS settings

If you are using KMS licensing, you need the KMS settings.

Prepare a new Platform Layer

  1. Select Layers > Platform Layers and select Create Platform Layer in the Action bar. This opens the Create Platform Layer wizard.

  2. In the Version Details tab:
    1. (Required) Enter a name for the New Version. This can be the software version or other identifying information.
    2. If you are adding a version to an existing layer, the Base Version field lets you choose which version to use as the starting point. The default choice is the latest version. 
       
  3. In the OS Layer tab, select the OS Layer you want to associate with this Platform Layer.

  4. In the Connector tab, choose a Hyper-V Connector Configuration. If the configuration you need isn't listed, click New, select Hyper-V, and click Add a Configuration.

  5. In the Platform Types tab, select the radio button that describes the purpose of this Platform Layer: to create and update layers, or to publish Layered Images. 

  6. From the drop-down menus, select the Hyper-V hypervisor, and the provisioning service and/or connection broker you are using, if any.

  7. In the Packaging Disk tab, enter a file name for the Packaging Disk, and select the disk format. This disk will be used for the Packaging Machine (the VM) where you will install the tools, as described in the next two sections.

  8. In the Icon Assignment tab, select an icon to assign to the layer. This icon represents the layer in the Layers Module.

    • To use an existing image, select an image in the image box.
    • To import a new image, click Browse and select an image in PNG or JPG format.
  9. In the Confirm and Complete tab, review the details of the Layer, enter a comment if required, and click Create Layer. Any comments you enter will appear in the Information view Audit History.

  10. At the bottom of the UI, expand the Tasks bar and double-click the task to show the full task description.

    Once the task is complete, a Packaging Machine is created in the location specified in the connector configuration. 

Deploy a Packaging Machine in Hyper-V

A link to the packaging machine is included In the Create Layer task description. 

  1. Log into Hyper-V. This is so you can navigate to the packaging machine in the next step.
  2. In the Management Console, expand the Task Panel, and then the Packaging Disk task. The task description includes a link to the Packaging Machine.
  3. Navigate to the Packaging Machine using the link provided in the Packaging Disk task.
  4. In Hyper-V, power on the Packaging Machine.

Install the platform tools on the Packaging Machine

Whether you are creating a Platform Layer or adding a version to it:

  1. Remote log in to the Packaging Machine. Be sure to log in using the User account you used to create the OS.

  2. Install the platform software and tools, along with any drivers, boot-level applications, or files needed. Keep in mind that the state of the software before you finalize the layer is what the image will use.

    • If this Platform Layer is going to be used for packaging new layers, install and configure your hypervisor tools and settings.
    • If this Platform Layer is going to be used for publishing Layered Images, install and configure your hypervisor, provisioning service, and connection broker tools and settings.
    • If a software installation requires a system restart, restart it manually. The Packaging Machine does not restart automatically.
  3. Make sure the Packaging Machine is in the state you want it to be in for users:

    • If the tools you install require any post-installation setup or registration, complete those steps now.
    • Remove any settings, configurations, files, mapped drives, or applications that you do not want to include on the Packaging Machine.
    • When using PVS, if your OS image was activated using KMS, rearm KMS just before you shut down

      1. Verify the Rearm count on the OS by running slmgr /dlv from a command prompt. The Rearm count must not be zero.

        slmgr /dlv

      2. Rearm KMS:

        slmgr /rearm

Verify the Layer and shut down the Packaging Machine

Once the software is installed on the Packaging Machine, it is important to verify that the Layer is ready to be finalized. To be ready for finalization, any required post-installation processing needs to be completed. For example, a reboot may be required, or a Microsoft NGen process may need to complete.

To verify that any outstanding processes are complete, you can run the Shutdown For Finalize tool. Look for the Shutdown for Finalize icon on the Packaging Machine's desktop.

To use the Shutdown For Finalize tool:

  1. If you are not logged into the Packaging Machine, remote log in as the user who created the machine.
  2. Double-click the Shutdown For Finalize icon. A command line window displays messages detailing the layer verification process.
  3. If there is an outstanding operation that must be completed before the Layer can be finalized, you are prompted to complete the process. For example, if a Microsoft NGen operation needs to complete, you may be able to expedite the NGen operation. For details, see Verifying Layers.
  4. If you are using KMS licensing, once any pending operations are complete, be sure to rearm KMS yet again just before you shutdown. First, enter this command to verify that the Rearm count is > 0:

    slmgr /dlv

    Then, rearm KMS:

    slmgr /rearm

  5. Double-click the Shutdown For Finalize icon again to shut down the Packaging Machine.

The Layer should be ready to finalize.

During the shutdown for finalization

Layer integrity messages let you know what queued tasks must be completed before a Layer is finalized.

The new Layer or Version can only be finalized when the following conditions have been addressed:

  • A reboot is pending to update drivers on the boot disk - please check and reboot the Packaging Machine.
  • A post-installation reboot is pending - please check and reboot the Packaging Machine.
  • An MSI install operation is in progress - please check the Packaging Machine.
  • A Microsoft NGen operation is in progress in the background.

Note

 If a Microsoft NGen operation is in progress, you may be able to expedite it, as described in the next section.

Expediting a Microsoft NGen operation

NGen is the Microsoft Native Image Generator. It is part of the .NET system, and basically re-compiles .NET byte code into native images and constructs the registry entries to manage them. Windows will decide when to run NGen, based on what is being installed and what Windows detects in the configuration. When NGen is running, you must let it complete. An interrupted NGen operation can leave you with non-functioning .NET assemblies or other problems in the .NET system.

You have the choice of waiting for the NGen to complete in the background, or you can force the NGen to the foreground. You can also check the status of the NGen operation, as described below. However, every time you check the queue status, you are creating foreground activity, which might cause the background processing to temporarily pause.

Forcing the NGen to the foreground will allow you to view the progress and once the output has completed, you should be able to finalize the layer.

  1. Force an NGen operation to the foreground.

    Normally, NGen is a background operation and will pause if there is foreground activity. Bringing the task into the foreground can help the task to complete as quickly as possible. To do this:

    1. Open a command prompt as Administrator.

    2. Go to the Microsoft .NET Framework directory for the version currently in use:

      cd C:\Windows\Microsoft.NET\FrameworkNN\vX.X.XXXXX

    3. Enter the NGen command to execute the queued items:

      ngen update /force

      This brings the NGen task to the foreground in the command prompt, and lists the assemblies being compiled.

      Note: It’s okay if you see several compilation failed messages!

    4. Look in the Task Manager to see if an instance of MSCORSVW.EXE is running. If it is, you must allow it to complete, or re-run ngen update /force. Do not reboot to stop the task. You must allow it to complete.
  2. Check the status of an NGen operation

    1. Open a command prompt as Administrator.

    2. Check status by running this command:

      ngen queue status

    3. When you receive the following status, the NGen is complete, and you can finalize the Layer.

      The .NET Runtime Optimization Service is stopped

Finalize the Layer

Now that the Layer has been verified and shut down, it is ready to finalize.

  1. Return to the App Layering Management Console.

  2. Select Layers > Platform Layers, and then the layer you just prepared.

  3. Select Finalize in the Action bar.

  4. Monitor the Task bar to verify that the action completes successfully and that the layer is ready to deploy.