Skip to content

Latest commit

 

History

History
72 lines (60 loc) · 4.46 KB

Library.md

File metadata and controls

72 lines (60 loc) · 4.46 KB

Ookii.AnswerFile library NuGet

The core functionality of the Answer File Generator is implemented in the Ookii.AnswerFile library, which you can integrate into your own applications. The library requires .Net 8.0 or later, and is available on NuGet.

To generate an answer file, you invoke the AnswerFileGenerator.Generate method, passing in an instance of the AnswerFileOptions class, which describes the various settings you want to use in the answer file.

To specify the install method, you set the AnswerFileOptions.InstallOptions property to an instance of the CleanEfiOptions, CleanBiosOptions, ExistingPartitionOptions, or ManualInstallOptions class. Additional options that are specific to an install method, such as partition layout or optional features, are set in those classes.

Leave the AnswerFileOptions.InstallOptions property set to null to generate an answer file for a pre-installed image, such as one created by sysprep or DISM tools.

The below example sets various options to perform a clean installation on a UEFI-based system, enabling some optional features and remote desktop. It creates a user account, and sets it to be logged on automatically at first boot.

var options = new AnswerFileOptions()
{
    InstallOptions = new CleanEfiOptions()
    {
        OptionalFeatures = new OptionalFeatures(new Version(10, 0, 22621, 1))
        {
            Features = { "Microsoft-Windows-Subsystem-Linux", "VirtualMachinePlatform" }
        }
    },
    EnableRemoteDesktop = true,
    LocalAccounts = { new LocalCredential("MyUser", "Password") },
    AutoLogon = new AutoLogonOptions(new DomainUser(null, "MyUser"), "Password"),
    ProductKey = "ABCDE-12345-ABCDE-12345-ABCDE",
    DisplayResolution = new Resolution(1920, 1080)
};

AnswerFileGenerator.Generate("unattend.xml", options);

For more information, check out the class library documentation.

Breaking changes

Version 2.0 of the library has a few breaking changes from version 1.x: