diff --git a/README.md b/README.md
index 18da1372..9ad55eb6 100644
--- a/README.md
+++ b/README.md
@@ -1,108 +1 @@
-# Tiny11 Builder
-
-**Build a smaller Windows 11 installer. Choose what stays.**
-
-Start with an official Microsoft image or your own ISO, choose the apps and
-features you want, and create your installer in a native Windows app.
-Your original source media is left unchanged.
-
-[**Download for Windows**](https://github.com/ntdevlabs/tiny11builder/releases/latest) ·
-[What's new in 0.2.0](docs/release-notes-0.2.0.md) ·
-[Watch the 0.2.0 demo](https://youtu.be/Ijp3J8SYqLc) ·
-[Get help or report a problem](https://github.com/ntdevlabs/tiny11builder/issues)
-
-
-
-## Get started
-
-1. **Download and extract the whole ZIP.** Choose **x64** for Intel/AMD PCs or
- **ARM64** for Windows on ARM.
-2. **Open `Tiny11Builder.exe`.** Approve the administrator prompt.
-3. **Choose your Windows image and what to keep.** Download an official image
- in the app or select your own, review your choices, then build your ISO.
-
-The app includes its .NET runtime. For image-tool requirements and a full
-walkthrough, see the [usage guide](docs/usage.md).
-
-## Pick a starting point
-
-| Choose | When it fits |
-| --- | --- |
-| **Tiny11** | A leaner image that keeps Windows Update, Defender and recovery. |
-| **Custom** | Choose removals yourself, or load a recipe and adjust it to your needs. |
-| **Tiny11 Core** | Disposable test VMs. Removes update and recovery support and disables Defender. |
-
-> **Try your image in a virtual machine first.** Core cannot be updated or
-> serviced. Advanced Custom removals can break Windows, apps or devices.
-
-## More control in 0.2.0
-
-- **Reuse a setup you like.** Load a recipe, review its selected removals,
- and adapt it to another Windows image.
-- **Know what will change.** Browse the Tiny11 and Core removal plans, or
- export a complete list of components for a closer look.
-- **Bring updates along.** Add local Windows update packages before building,
- in the order your image needs.
-- **Use your language.** English and Simplified Chinese are included.
- Additional languages can use [translation files](docs/translation.md).
-- **Go further with Custom.** Fine-tune individual removals and create a
- smaller installer from your own Windows image.
-
-Turbo mode speeds up processing. Interrupted builds can resume once a saved
-image checkpoint is available.
-
-[Read the full 0.2.0 release notes](docs/release-notes-0.2.0.md)
-
-## Watch what's new
-
-[](https://youtu.be/Ijp3J8SYqLc)
-
-## A look inside
-
-| See what a preset removes | Check your build before starting |
-| --- | --- |
-|  |  |
-
-## Compatibility and advanced use
-
-Windows 11 images from **22H2 onward** are supported. Insider and Canary builds
-need compatible Microsoft image tools; Windows Server is not supported.
-See [requirements and compatibility](docs/usage.md) before choosing a source.
-
-
-Looking for deeper customization or a very small image?
-
-Custom includes individual app, component, service, file, driver and font
-removals, plus optional installer cleanup.
-
-The bundled [extreme recipe](recipes/cd700-custom.json) is a starting point
-for experimenting with much smaller images, not another build mode.
-CD size is an optional target, not a guarantee for every Windows image.
-Test the result in an isolated virtual machine.
-
-See the [usage guide](docs/usage.md) for the controls and their tradeoffs.
-
-
-
-## Help keep the next update coming
-
-Tiny11 Builder grows through testing and feedback from people using it.
-If it saves you time, a contribution helps fund development, testing across
-Windows releases, and fixes for real-world problems.
-
-**[Sponsor monthly](https://github.com/sponsors/ntdevlabs)** ·
-**[Send a one-time thanks](https://ko-fi.com/ntdev)**
-
-You can also use [Patreon](https://www.patreon.com/ntdev) or
-[PayPal](https://paypal.me/ntdev2).
-
-**Every feature is free, whether you donate or not.** Clear bug reports,
-testing in a VM, and sharing the [demo](https://youtu.be/Ijp3J8SYqLc) help too.
-
----
-
-[Usage and build instructions](docs/usage.md) ·
-[Translation guide](docs/translation.md) ·
-[Attribution and distribution notices](NOTICE.md)
-
-The original PowerShell builders remain in this repository.
+Tiny11 Builder is now with Nano11 Builder!
diff --git a/docs/usage.md b/docs/usage.md
index ee4b4184..2d660612 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -19,13 +19,25 @@ unchanged below for compatibility.
| --- | --- |
| Tiny11 | The fixed original-style removal set: bundled apps, Edge/WebView2 and OneDrive binaries, hardware-check settings, reserved-storage and automatic-encryption settings. Keeps Update, Defender, WinRE, Store and shared runtimes. Choose Custom to edit removals. |
| Tiny11 Core | Applies changes before resetting the component base. Keeps common-controls/GDI+/CRT/servicing files, deletes other WinSxS component folders, removes WinRE and disables Windows Update and Defender. These changes cannot be reversed. Use only for test VMs. |
+| Nano11 | Core's removals plus the reductions from the nano11 builder, and always the smallest output settings (recovery-ESD installation image, redundant data removed, no staged .NET 3.5 setup payload, rebuilt single-index `boot.wim`). Those four settings are shown but locked while Nano11 is selected: a longer app and package list, direct payload, driver-store and font removal, deleted services, and a component store replaced by only the retained runtime and servicing families (WinSxS is deleted and rebuilt from that list). Not a Windows 11 replacement. |
| Custom | Starts with no removals selected. Choose individual removal groups or list preinstalled apps, protected system apps, optional features, language capabilities, CBS packages, services, drivers and WinSxS component folders. Features and services also offer disable-only. Core's irreversible removals are a separate, unchecked option with the same warning and acknowledgement. |
The presets are original-style, not command-for-command copies of the scripts.
Tiny11 cleans superseded components without `/ResetBase`, preserving the
ability to uninstall existing updates. Core does reset the base, retains
additional detected runtime/servicing families, and removes WinRE without
-creating the original script's empty placeholder. These compatibility choices
+creating the original script's empty placeholder.
+
+Nano11 mirrors nano11.ps1: it names 39 provisioned-app fragments, 31 package
+and capability families, direct payloads (Edge, WebView2, OneDrive setup, four
+IME folders, Web/Help/Cursors, TTS engines, Defender definitions, Temp), the
+printer/scanner/multi-function driver classes, all fonts except the plan's
+Latin families, five scheduled tasks and 14 services, then deletes WinSxS and
+rebuilds it from the retained families. It also keeps the original builder's
+empty `Recovery\winre.wim` placeholder. Audio services are deliberately not
+removed. Nano11 reads the image's own default UI language and architecture
+instead of asking, and it refuses to start its store replacement when a
+required family is missing rather than producing an unbootable image. These compatibility choices
are unchanged by the reliability update; further reductions require separate
Setup/boot testing.
@@ -81,8 +93,11 @@ The six-step wizard provides:
not a VM-only DVD-disconnection workaround; Windows licensing and
activation requirements are unchanged.
- Optional .NET 3.5 from matching `sources\sxs`, compact installation, and
- best-effort local-account setup. No account, password, product key, automatic
- logon or EULA acceptance is injected.
+ best-effort local-account setup. Media without that payload (some 21H2
+ images) disables the option with the reason shown next to it, and a build
+ that still requests it stops before any stage runs rather than after
+ servicing has started. No account, password, product key, automatic logon
+ or EULA acceptance is injected.
- Automatic image-tool detection and compatible-version checks. oscdimg is
found locally or downloaded from Microsoft's symbol server with an exact
SHA-256 pin. No tool-selection controls or script execution-policy changes.
@@ -118,7 +133,7 @@ extreme removal profile. Its source, workspace, output and tool paths are
empty intentionally: loading it keeps your current local paths and selected
edition, or lets you choose any supported Windows 11 ISO afterward. It is
not tied to a prepared image, language, edition or architecture. Supported
-means Windows 11 client x64/ARM64, 22H2 or newer, with compatible tools;
+means Windows 11 client x64/ARM64, 21H2 (22000) or newer, with compatible tools;
unknown Insider builds still need a compatible engine.
Every selected removal group appears **checked** in Components, including
@@ -351,9 +366,16 @@ around by disabling certificate validation. Follow the reported trust problem
and use a current complete Microsoft toolset.
Windows Server images are outside the supported client-image scope.
-The engine accepts **Windows 11 client builds 22621 (22H2) and newer**, including
-23H2, 24H2, 25H2, 26H2 and Insider/Canary media, in **x64 and ARM64**, without a
-hard-coded maximum build number. Image architecture, edition and version are
+The engine accepts **Windows 11 client builds 22000 (21H2) and newer**, including
+22H2, 23H2, 24H2, 25H2, 26H2 and Insider/Canary media, in **x64 and ARM64**,
+without a hard-coded maximum build number.
+
+21H2 is the original Windows 11 release and predates the removal plans written
+for 22H2 and newer. It is accepted, but treat it as a legacy source: some
+preset targets do not exist in that build and are reported as *not present*
+rather than guessed, and the installer, WinRE and servicing behaviour differ
+from later releases. Keep a current Microsoft image toolset and confirm the
+result in a VM. Image architecture, edition and version are
read from DISM, not inferred from the ISO filename. Package/capability/feature
identities come from the mounted image, so missing items are logged as *not
present*, rather than guessed.
diff --git a/src/Tiny11Builder.App/Languages/en.json b/src/Tiny11Builder.App/Languages/en.json
index 6027ebdb..53ff7dfd 100644
--- a/src/Tiny11Builder.App/Languages/en.json
+++ b/src/Tiny11Builder.App/Languages/en.json
@@ -241,7 +241,6 @@
"Text.SelectCustomAndChooseAWindowsISO": "Choose Custom removals or load a saved JSON recipe.",
"Text.SelectIndividualAppsComponentsAndServicesToRemove": "Select individual apps, components and services to remove.",
"Text.ProtectedItemsIncluded": "Protected items included",
- "Text.Windows1122H2OrNewerX64AndARM64Insider": "Windows 11 22H2 or newer · x64 and ARM64 · Insider / Canary",
"Text.TestCoreAndCustomImagesInAVMBefore": "Test Core and custom images in a VM before use.",
"Text.DownloadTheLatestWindows11FromMicrosoftOrSelect": "Download the latest Windows 11 from Microsoft, or select an ISO or extracted installation folder. Inspect the image to select an edition.",
"Text.LocalInstallationMedia": "Local installation media",
@@ -266,7 +265,7 @@
"Text.CopyFromMicrosoftSVerifyYourDownloadSection": "Copy from Microsoft's Verify your download section",
"Text.DownloadISOResumePartial": "Download ISO / resume partial",
"Text.Components": "Components",
- "Text.ChooseTiny11Tiny11CoreOrSelectYourOwnRemovals": "Choose Tiny11, Tiny11 Core, or select your own removals with Custom. Every change is recorded in the build log.",
+ "Text.ChooseTiny11Tiny11CoreOrSelectYourOwnRemovals": "Choose Tiny11, Tiny11 Core, Nano11, or select your own removals with Custom. Every change is recorded in the build log.",
"Text.UseTiny11": "Use Tiny11",
"Text.OriginalRemovalsKeepUpdateSupport": "Original removals. Keep update support.",
"Text.UseTiny11Core": "Use Tiny11 Core",
@@ -409,7 +408,6 @@
"Text.SupportOptionsCouldNotBeOpened": "Support options could not be opened.",
"Text.ThisSupportLinkHasNoValidDestination": "This support link has no valid destination.",
"Text.ThisEditionIsNotSupported": "This edition is not supported.",
- "Text.ChooseAWindows11ClientImage22H2OrNewer": "Choose a Windows 11 client image, 22H2 or newer, in x64 or ARM64 format.",
"Text.AdministratorPrivilegesRequired": "Administrator privileges required.",
"Text.CloseAndReopenTiny11BuilderExeThenApproveTheWindows": "Close and reopen Tiny11Builder.exe, then approve the Windows administrator prompt.",
"Text.ImageSelected": "Image selected.",
@@ -690,6 +688,17 @@
"Text.Joined657": "Recover discards a job's working copy, and it does not do that for a job with saved progress. Resume continues the build from that progress instead.\n\nNothing has been changed.",
"Text.Joined658": "Select only job.json from the interrupted tiny11 job. This discards that job's mounted working copy and removes its staged media. Its logs, recipe, report and your source ISO are kept. A job whose image was already committed has saved progress and is never discarded here; use Resume build for it. Active builds cannot be recovered.",
"Image.ServerUnsupported": "Windows Server images are not supported.",
- "Preset.EdgePolicyWithFileRemoval": "Suppress first-run, sidebar and recommendations. This preset also removes Edge and WebView2 files through its separate file-removal group."
+ "Preset.EdgePolicyWithFileRemoval": "Suppress first-run, sidebar and recommendations. This preset also removes Edge and WebView2 files through its separate file-removal group.",
+ "Text.Windows1121H2OrNewerX64AndARM64Insider": "Windows 11 21H2 or newer · x64 and ARM64 · Insider / Canary",
+ "Text.ChooseAWindows11ClientImage21H2OrNewer": "Choose a Windows 11 client image, 21H2 or newer, in x64 or ARM64 format.",
+ "Image.LegacyReleaseNote": "Windows 11 21H2 is an older codebase. Removals that do not exist in this image are skipped and logged.",
+ "Text.ThisSourceHasNoNetFxPayload": "This source has no sources\\sxs payload, so .NET 3.5 cannot be enabled from it.",
+ "Mode.Nano11": "Nano11",
+ "Review.NanoWarning": "Nano11 is not a Windows 11 replacement: updates, recovery, Defender, component servicing, printers, most fonts and many drivers are gone. Test it in an isolated VM.",
+ "Text.SelectNano11AndChooseAWindowsISO": "Select Nano11 and choose a Windows ISO.",
+ "Text.CorePlusAStrippedComponentStoreDriversAndFonts": "Core plus a stripped component store, drivers and fonts. The smallest mode.",
+ "Text.NotAWindowsReplacement": "Not a Windows replacement",
+ "Text.UseNano11": "Use Nano11",
+ "Text.SmallestImageTestVMsOnly": "Smallest image. Test VMs only."
}
}
diff --git a/src/Tiny11Builder.App/Languages/zh-Hans.json b/src/Tiny11Builder.App/Languages/zh-Hans.json
index 1158bb94..9a798118 100644
--- a/src/Tiny11Builder.App/Languages/zh-Hans.json
+++ b/src/Tiny11Builder.App/Languages/zh-Hans.json
@@ -241,7 +241,6 @@
"Text.SelectCustomAndChooseAWindowsISO": "选择自定义移除项或加载已保存的 JSON 配方。",
"Text.SelectIndividualAppsComponentsAndServicesToRemove": "自行选择要移除的应用、组件和服务。",
"Text.ProtectedItemsIncluded": "包含受保护的组件",
- "Text.Windows1122H2OrNewerX64AndARM64Insider": "Windows 11 22H2 或更高版本 · x64 和 ARM64 · Insider/Canary",
"Text.TestCoreAndCustomImagesInAVMBefore": "使用 Core 或自定义映像之前,请先在虚拟机中测试。",
"Text.DownloadTheLatestWindows11FromMicrosoftOrSelect": "从微软下载最新的 Windows 11,或选择本地 ISO/已解压的安装文件夹。检查映像后即可选择要构建的版本。",
"Text.LocalInstallationMedia": "本地安装介质",
@@ -266,7 +265,7 @@
"Text.CopyFromMicrosoftSVerifyYourDownloadSection": "从微软“验证下载”部分复制",
"Text.DownloadISOResumePartial": "下载 ISO/继续未完成的下载",
"Text.Components": "组件",
- "Text.ChooseTiny11Tiny11CoreOrSelectYourOwnRemovals": "选择 Tiny11、Tiny11 Core,或使用自定义模式自行选择移除项。所有更改都会记录到构建日志。",
+ "Text.ChooseTiny11Tiny11CoreOrSelectYourOwnRemovals": "选择 Tiny11、Tiny11 Core、Nano11,或使用 Custom 自行选择要移除的内容。所有更改都会记录在构建日志中。",
"Text.UseTiny11": "使用 Tiny11",
"Text.OriginalRemovalsKeepUpdateSupport": "原版移除设置,保留更新支持。",
"Text.UseTiny11Core": "使用 Tiny11 Core",
@@ -409,7 +408,6 @@
"Text.SupportOptionsCouldNotBeOpened": "无法打开支持方式选择界面。",
"Text.ThisSupportLinkHasNoValidDestination": "此支持链接没有有效的目标地址。",
"Text.ThisEditionIsNotSupported": "不支持此版本。",
- "Text.ChooseAWindows11ClientImage22H2OrNewer": "请选择 Windows 11 22H2 或更高版本的客户端映像,体系结构须为 x64 或 ARM64。",
"Text.AdministratorPrivilegesRequired": "需要管理员权限。",
"Text.CloseAndReopenTiny11BuilderExeThenApproveTheWindows": "请关闭并重新打开 Tiny11Builder.exe,然后在 Windows 管理员权限提示中选择允许。",
"Text.ImageSelected": "已选择映像。",
@@ -690,6 +688,17 @@
"Text.Joined657": "“恢复工作区”会丢弃作业的工作副本,但不会丢弃已有保存进度的作业。请改用“恢复构建”,从已保存的进度继续。\n\n未进行任何更改。",
"Text.Joined658": "请仅选择中断的 tiny11 作业中的 job.json。这会丢弃该作业挂载的工作副本,并移除暂存的安装介质。日志、配置、报告和源 ISO 将保留。映像已经提交的作业具有已保存的进度,此处绝不会将其丢弃;请对这类作业使用“恢复构建”。正在运行的构建不能恢复工作区。",
"Image.ServerUnsupported": "不支持 Windows Server 映像。",
- "Preset.EdgePolicyWithFileRemoval": "抑制首次运行提示、侧边栏和推荐内容。此预设还会通过单独的文件移除分组删除 Edge 和 WebView2 文件。"
+ "Preset.EdgePolicyWithFileRemoval": "抑制首次运行提示、侧边栏和推荐内容。此预设还会通过单独的文件移除分组删除 Edge 和 WebView2 文件。",
+ "Text.Windows1121H2OrNewerX64AndARM64Insider": "Windows 11 21H2 或更高版本 · x64 和 ARM64 · Insider/Canary",
+ "Text.ChooseAWindows11ClientImage21H2OrNewer": "请选择 Windows 11 21H2 或更高版本的客户端映像,体系结构须为 x64 或 ARM64。",
+ "Image.LegacyReleaseNote": "Windows 11 21H2 是较旧的代码库。此映像中不存在的移除项将被跳过并记录到日志。",
+ "Text.ThisSourceHasNoNetFxPayload": "此源没有 sources\\sxs 载荷,因此无法从中启用 .NET 3.5。",
+ "Mode.Nano11": "Nano11",
+ "Review.NanoWarning": "Nano11 不能替代 Windows 11:更新、恢复环境、Defender、组件服务、打印机、大部分字体和许多驱动程序均已被移除。请在隔离的虚拟机中测试。",
+ "Text.SelectNano11AndChooseAWindowsISO": "选择 Nano11 并选择一个 Windows ISO。",
+ "Text.CorePlusAStrippedComponentStoreDriversAndFonts": "在 Core 基础上进一步精简组件存储、驱动和字体,是体积最小的模式。",
+ "Text.NotAWindowsReplacement": "不能替代 Windows",
+ "Text.UseNano11": "使用 Nano11",
+ "Text.SmallestImageTestVMsOnly": "体积最小的映像,仅供测试虚拟机使用。"
}
}
diff --git a/src/Tiny11Builder.App/MainWindow.xaml b/src/Tiny11Builder.App/MainWindow.xaml
index 40b7290a..33e40eb8 100644
--- a/src/Tiny11Builder.App/MainWindow.xaml
+++ b/src/Tiny11Builder.App/MainWindow.xaml
@@ -111,10 +111,10 @@
-
+
-
+
+
-
+
@@ -226,17 +241,18 @@
-
+
+
-
-
+
+
@@ -246,6 +262,9 @@
+
-
+
diff --git a/src/Tiny11Builder.App/MainWindow.xaml.cs b/src/Tiny11Builder.App/MainWindow.xaml.cs
index 11cd4ab5..ae815b5f 100644
--- a/src/Tiny11Builder.App/MainWindow.xaml.cs
+++ b/src/Tiny11Builder.App/MainWindow.xaml.cs
@@ -38,6 +38,8 @@ public sealed partial class MainWindow : Window
private bool resultTurbo;
private int resultUpdateCount;
private bool coreAcknowledged;
+ // False when the inspected media has no sources\sxs, so .NET 3.5 cannot be enabled offline from it.
+ private bool hasNetFx3Payload = true;
private bool modalOpen;
private enum NoticeAction { None, OpenLogs, CopyDetails, OpenTools, OpenOfficialDownload }
private string officialDownloadPage = OfficialImageDownloader.DownloadPage;
@@ -157,7 +159,7 @@ public MainWindow()
private FrameworkElement[] Panels => [WelcomePanel, SourcePanel, CleanupPanel, SettingsPanel, ReviewPanel, BuildPanel];
private BuildMode SelectedMode => (BuildMode)ModeChoice.SelectedIndex;
- private bool UsesCore => SelectedMode == BuildMode.Tiny11Core ||
+ private bool UsesCore => SelectedMode is BuildMode.Tiny11Core or BuildMode.Nano11 ||
(SelectedMode == BuildMode.Custom && CustomCoreCheck.IsOn);
private static string HostArchitecture => RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "arm64" : "x64";
@@ -173,9 +175,9 @@ private void UpdateWelcomeLayout()
if (WelcomePanel is null || ModeCards is null || RemovalModeCards is null || ReviewCards is null || SourceCards is null) return;
var padding = ContentScroller.Padding;
WelcomePanel.MinHeight = Math.Max(0, ContentScroller.ActualHeight - padding.Top - padding.Bottom);
- var stacked = ContentScroller.ActualWidth - padding.Left - padding.Right < 560;
- ArrangeModeCards(ModeCards, [RegularModeCard, CoreModeCard, CustomModeCard], stacked);
- ArrangeModeCards(RemovalModeCards, [Tiny11Selection, CoreSelection, CustomSelection], stacked);
+ var stacked = ContentScroller.ActualWidth - padding.Left - padding.Right < 760;
+ ArrangeModeCards(ModeCards, [RegularModeCard, CoreModeCard, CustomModeCard, NanoModeCard], stacked);
+ ArrangeModeCards(RemovalModeCards, [Tiny11Selection, CoreSelection, CustomSelection, NanoSelection], stacked);
ArrangeSourceCards(ContentScroller.ActualWidth - padding.Left - padding.Right);
ReviewCards.ColumnDefinitions[1].Width = stacked ? new GridLength(0) : new GridLength(1, GridUnitType.Star);
FrameworkElement[] review = [ReviewImageCard, ReviewModeCard, ReviewPathsCard, ReviewOptionsCard];
@@ -393,24 +395,35 @@ await Task.Run(() =>
});
}
- private BuildRecipe CreateRecipe() => new()
- {
- SourcePath = SourcePathBox.Text.Trim(), ImageIndex = image?.Index ?? 1,
- WorkspacePath = WorkspaceBox.Text.Trim(), OutputPath = OutputBox.Text.Trim(),
- DismPath = servicingTool, OscdimgPath = isoTool,
- Mode = SelectedMode, Flavor = UsesCore ? BuildFlavor.Core : BuildFlavor.Regular,
- CoreAcknowledged = coreAcknowledged, ExpertAcknowledged = ExpertAccepted,
- SelectedOptions = options.Where(o => o.Selected).Select(o => o.Option.Id).ToArray(),
- ExpertActions = inventory.Count > 0 ? inventory.Where(i => i.Selected).Select(i => i.Action).ToArray() : pendingActions,
- Compression = (Compression)CompressionChoice.SelectedIndex,
- CompactInstallation = CompactCheck.IsOn, EnableNetFx3 = NetFxCheck.IsOn,
- PreferLocalAccount = LocalAccountCheck.IsOn, KeepWorkingFiles = KeepFilesCheck.IsOn,
- TurboMode = TurboCheck.IsOn, RemoveRedundantData = RedundantDataCheck.IsOn,
- OmitNetFx3SetupPayload = OmitSetupCheck.IsOn,
- UpdatePackages = updatePackages.Paths,
- IsoSizeLimitBytes = SelectedMode == BuildMode.Custom ? recipeIsoSizeLimit : null,
- ShrinkBootImage = SelectedMode == BuildMode.Custom && ShrinkBootCheck.IsChecked == true
- };
+ // Nano11 always builds its smallest output, so the recipe reflects that here: the review, the validation and the
+ // build all describe the same settings.
+ private BuildRecipe CreateRecipe()
+ {
+ var recipe = new BuildRecipe
+ {
+ SourcePath = SourcePathBox.Text.Trim(), ImageIndex = image?.Index ?? 1,
+ WorkspacePath = WorkspaceBox.Text.Trim(), OutputPath = OutputBox.Text.Trim(),
+ DismPath = servicingTool, OscdimgPath = isoTool,
+ CoreAcknowledged = coreAcknowledged, ExpertAcknowledged = ExpertAccepted,
+ SelectedOptions = options.Where(o => o.Selected).Select(o => o.Option.Id).ToArray(),
+ ExpertActions = inventory.Count > 0 ? inventory.Where(i => i.Selected).Select(i => i.Action).ToArray() : pendingActions,
+ Compression = (Compression)CompressionChoice.SelectedIndex,
+ CompactInstallation = CompactCheck.IsOn, EnableNetFx3 = NetFxCheck.IsOn,
+ PreferLocalAccount = LocalAccountCheck.IsOn, KeepWorkingFiles = KeepFilesCheck.IsOn,
+ TurboMode = TurboCheck.IsOn, RemoveRedundantData = RedundantDataCheck.IsOn,
+ OmitNetFx3SetupPayload = OmitSetupCheck.IsOn,
+ UpdatePackages = updatePackages.Paths,
+ IsoSizeLimitBytes = SelectedMode == BuildMode.Custom ? recipeIsoSizeLimit : null,
+ ShrinkBootImage = SelectedMode is BuildMode.Custom or BuildMode.Nano11 && ShrinkBootCheck.IsChecked == true
+ };
+ recipe = recipe with
+ {
+ Mode = SelectedMode,
+ Flavor = SelectedMode == BuildMode.Nano11 ? BuildFlavor.Nano : UsesCore ? BuildFlavor.Core : BuildFlavor.Regular
+ };
+ // The engine applies this too, so a recipe that never passed through the app still builds the smallest ISO.
+ return SelectedMode == BuildMode.Nano11 ? recipe.WithSmallestOutput() : recipe;
+ }
private async Task RunOperation(OperationKind kind, Func action)
{
@@ -777,7 +790,7 @@ private void OnEditionChanged(object sender, SelectionChangedEventArgs args)
ShowNotice(image.Installation.StartsWith("Server", StringComparison.OrdinalIgnoreCase) ||
image.Name.Contains("Windows Server", StringComparison.OrdinalIgnoreCase) ?
UiText.Get("Image.ServerUnsupported") : UiText.FromEnglish("This edition is not supported."),
- UiText.FromEnglish("Choose a Windows 11 client image, 22H2 or newer, in x64 or ARM64 format."), InfoBarSeverity.Warning);
+ UiText.FromEnglish("Choose a Windows 11 client image, 21H2 or newer, in x64 or ARM64 format."), InfoBarSeverity.Warning);
UpdateNavigation();
}
@@ -806,7 +819,13 @@ private async Task InspectSourceAsync(CancellationToken token)
var restored = source.Equals(pendingSourcePath, StringComparison.OrdinalIgnoreCase) ? pendingImageIndex : null;
EditionChoice.ItemsSource = images;
EditionChoice.SelectedIndex = ImageDefaults.SelectPosition(images, restored);
+ // Older media can omit sources\sxs; say so where the build options are chosen, not mid-build.
+ hasNetFx3Payload = Directory.Exists(Path.Combine(source, @"sources\sxs"));
+ NetFxPayloadNote.Visibility = hasNetFx3Payload ? Visibility.Collapsed : Visibility.Visible;
+ if (!hasNetFx3Payload) NetFxCheck.IsOn = false;
ShowNotice(UiText.Get("Image.Inspected"), UiText.Format("Image.EditionsFound", images.Count, image?.Name) +
+ (image?.IsLegacyRelease == true ? " " + UiText.Get("Image.LegacyReleaseNote") : "") +
+ (hasNetFx3Payload ? "" : " " + UiText.Get("Text.ThisSourceHasNoNetFxPayload")) +
(SkippedImageTools ? " " + UiText.Get("Tools.TrustedFallback") : ""),
SkippedImageTools ? InfoBarSeverity.Warning : InfoBarSeverity.Informational,
SkippedImageTools ? NoticeAction.CopyDetails : NoticeAction.None,
@@ -1072,7 +1091,7 @@ private void ApplyMode()
private void UpdateModePresentation()
{
CustomChoices.Visibility = SelectedMode == BuildMode.Custom ? Visibility.Visible : Visibility.Collapsed;
- CustomMediaSettings.Visibility = SelectedMode == BuildMode.Custom ? Visibility.Visible : Visibility.Collapsed;
+ CustomMediaSettings.Visibility = SelectedMode is BuildMode.Custom or BuildMode.Nano11 ? Visibility.Visible : Visibility.Collapsed;
PresetPreview.Visibility = SelectedMode == BuildMode.Custom ? Visibility.Collapsed : Visibility.Visible;
var presetOptions = PresetRemovalPreview.ForMode(SelectedMode);
var presetRemovesEdgeFiles = presetOptions.Any(option => option.Id == "edge-files");
@@ -1085,12 +1104,14 @@ private void UpdateModePresentation()
{
BuildMode.Tiny11 => "Original Tiny11 removals, including Edge/WebView2 and OneDrive binaries. Windows Update, Defender and recovery are kept. Choose Custom to change individual removals.",
BuildMode.Tiny11Core => "Tiny11 Core removals, including irreversible component pruning. Choose Custom to change individual removals.",
+ BuildMode.Nano11 => "Core plus Nano11: smaller apps, features, drivers, fonts, services and a component store limited to the retained runtime and servicing families. Not a Windows replacement.",
_ => "Start with nothing selected, then choose what to remove or disable. You can also list individual components, including protected items."
});
SourceMode.Text = UiText.Format("Mode.Selected", (ModeChoice.SelectedItem as ComboBoxItem)?.Content);
MarkChoice(Tiny11Selection, SelectedMode == BuildMode.Tiny11);
MarkChoice(CoreSelection, SelectedMode == BuildMode.Tiny11Core);
MarkChoice(CustomSelection, SelectedMode == BuildMode.Custom);
+ MarkChoice(NanoSelection, SelectedMode == BuildMode.Nano11);
}
// The chosen card gets an accent outline and is announced as selected; unchosen cards keep full-strength text.
@@ -1099,6 +1120,29 @@ private static void MarkChoice(Button card, bool selected)
card.Style = (Style)Application.Current.Resources[selected ? "ModeCardSelected" : "ModeCard"];
Microsoft.UI.Xaml.Automation.AutomationProperties.SetItemStatus(card, UiText.Get(selected ? "Common.Selected" : "Common.NotSelected"));
}
+ private bool applyingSmallest;
+
+ ///
+ /// Nano11 builds the smallest ISO it can, so its output settings are shown as they will be built and cannot be
+ /// relaxed into a larger image. Every other mode keeps its own settings, so a Tiny11 or Core build can still be
+ /// made smaller by hand here.
+ ///
+ private void ApplySmallestOutput(bool smallest)
+ {
+ if (applyingSmallest) return;
+ applyingSmallest = true;
+ if (smallest)
+ {
+ CompressionChoice.SelectedIndex = (int)Compression.Recovery;
+ RedundantDataCheck.IsOn = true;
+ OmitSetupCheck.IsOn = true;
+ ShrinkBootCheck.IsChecked = true;
+ }
+ foreach (var control in new Control[] { CompressionChoice, RedundantDataCheck, OmitSetupCheck, ShrinkBootCheck })
+ control.IsEnabled = !smallest;
+ applyingSmallest = false;
+ }
+
private void OnChoicesChanged(object sender, RoutedEventArgs args)
{
if (!initialized || applyingMode) return;
@@ -1127,6 +1171,7 @@ private void UpdateCounts()
NativePayloadWarning.IsOpen = directGroups;
NativePayloadConsent.Visibility = directGroups ? Visibility.Visible : Visibility.Collapsed;
RecipeLimitPanel.Visibility = SelectedMode == BuildMode.Custom && recipeIsoSizeLimit is not null ? Visibility.Visible : Visibility.Collapsed;
+ ApplySmallestOutput(SelectedMode == BuildMode.Nano11);
RecipeLimitText.Text = recipeIsoSizeLimit is { } limit ? UiText.Format("CustomMedia.ReviewLimit", limit) : "";
ExportInventoryButton.IsEnabled = !busy && inventory.Count > 0;
UpdateNavigation();
@@ -1204,7 +1249,7 @@ private string CreateReview()
void Row(string key, object? value) => text.AppendLine(UiText.Format(key, value));
Row("Review.Image", image?.Summary ?? UiText.Get("Image.NotInspected"));
Row("Review.Mode", (ModeChoice.SelectedItem as ComboBoxItem)?.Content);
- if (SelectedMode == BuildMode.Custom) Row("Review.CoreRemovals", YesNo(UsesCore));
+ if (SelectedMode is BuildMode.Custom) Row("Review.CoreRemovals", YesNo(UsesCore));
if (recipe.IsoSizeLimitBytes is { } limit) Row("CustomMedia.ReviewLimit", limit);
Row("Review.Source", recipe.SourcePath);
Row("Review.Output", recipe.OutputPath);
@@ -1228,6 +1273,7 @@ private string CreateReview()
text.AppendLine();
text.AppendLine(UiText.Get("Review.UnselectedKept"));
if (recipe.Flavor == BuildFlavor.Core) text.AppendLine(UiText.Get("Review.CoreWarning"));
+ if (recipe.Flavor == BuildFlavor.Nano) text.AppendLine(UiText.Get("Review.NanoWarning"));
if (recipe.ExpertActions.Length > 0) text.AppendLine(UiText.Get("Review.ExpertWarning"));
text.AppendLine(UiText.Get("Review.PolicyWarning"));
return text.ToString();
diff --git a/src/Tiny11Builder.App/OperationFlow.cs b/src/Tiny11Builder.App/OperationFlow.cs
index a147f051..538f81c1 100644
--- a/src/Tiny11Builder.App/OperationFlow.cs
+++ b/src/Tiny11Builder.App/OperationFlow.cs
@@ -245,6 +245,7 @@ public static string Describe(BuildRecipe recipe)
var mode = CleanupCatalog.ModeForRecipe(recipe) switch
{
BuildMode.Tiny11 => "Tiny11", BuildMode.Tiny11Core => "Tiny11 Core",
+ BuildMode.Nano11 => UiText.Get("Mode.Nano11"),
_ => UiText.Get(recipe.Flavor == BuildFlavor.Core ? "Resume.CustomCore" : "Mode.Custom")
};
var compression = UiText.Get(recipe.Compression switch
@@ -260,6 +261,7 @@ public static string Describe(BuildRecipe recipe)
text.AppendLine();
text.AppendLine(UiText.Get("Resume.FrozenChoices"));
if (recipe.Flavor == BuildFlavor.Core) text.AppendLine(UiText.Get("Resume.CoreWarning"));
+ if (recipe.Flavor == BuildFlavor.Nano) text.AppendLine(UiText.Get("Review.NanoWarning"));
if (SetupLabels.Legacy(recipe) is { } legacy) text.AppendLine(legacy + ".");
if (recipe.ExpertActions.Length > 0) text.AppendLine(UiText.Get("Resume.ExpertWarning"));
text.AppendLine();
@@ -278,6 +280,7 @@ internal static class SetupLabels
if (!SetupInstaller.RequiresLegacy(recipe)) return null;
var core = recipe.Flavor == BuildFlavor.Core;
var payload = recipe.ExpertActions.Any(a => a.Kind == ImageItemKind.ComponentPayload && a.Mode == ExpertActionMode.Remove);
+ if (recipe.Flavor == BuildFlavor.Nano) return UiText.FromEnglish(payload ? "Nano11 and component-payload removals" : "Nano11 removals");
return UiText.FromEnglish(core && payload ? "Core and component-payload removals" : core ? "Core removals" :
payload ? "component-payload removals" : "the selected removals");
}
diff --git a/src/Tiny11Builder.Core/BuildEngine.Cleanup.cs b/src/Tiny11Builder.Core/BuildEngine.Cleanup.cs
index 70897baa..b8352fc8 100644
--- a/src/Tiny11Builder.Core/BuildEngine.Cleanup.cs
+++ b/src/Tiny11Builder.Core/BuildEngine.Cleanup.cs
@@ -24,7 +24,8 @@ private static async Task CleanComponentsAsync(BuildSession s, CancellationToken
}
try
{
- await s.Dism.RunAsync(token, s.Recipe.Flavor == BuildFlavor.Core ?
+ // Core and Nano11 reset the base: both prune component payloads afterwards, so superseded copies are useless.
+ await s.Dism.RunAsync(token, s.Recipe.Flavor is BuildFlavor.Core or BuildFlavor.Nano ?
[$"/Image:{s.Mount}", "/Cleanup-Image", "/StartComponentCleanup", "/ResetBase"] :
[$"/Image:{s.Mount}", "/Cleanup-Image", "/StartComponentCleanup"]).ConfigureAwait(false);
}
diff --git a/src/Tiny11Builder.Core/BuildEngine.Nano.cs b/src/Tiny11Builder.Core/BuildEngine.Nano.cs
new file mode 100644
index 00000000..39c13d4a
--- /dev/null
+++ b/src/Tiny11Builder.Core/BuildEngine.Nano.cs
@@ -0,0 +1,180 @@
+using System.Text.RegularExpressions;
+
+namespace Tiny11Builder.Core;
+
+public sealed partial class BuildEngine
+{
+ private const string NanoStage = "Nano11 reductions";
+
+ /// What a Nano11 reduction operates on: the session, its mount, and the image architecture.
+ private sealed record Nano11Target(BuildSession Session, string Mount, string Architecture);
+
+ ///
+ /// The Nano11 stage: the reductions nano11.ps1 performs beyond Core. Order matters. The component base is cleaned
+ /// and reset first, packages and payloads go next, and the component store is replaced last, so a failure before
+ /// the swap leaves the original WinSxS in place. Everything happens while the image is still mounted and a single
+ /// commit carries it. Optional targets that are absent are skipped; only the retained families are required.
+ ///
+ private async Task TrimNano11Async(BuildSession s, CancellationToken token)
+ {
+ s.Stage(NanoStage, "Removing Nano11's additional apps, payloads, drivers, fonts, services and component families.", token);
+ var target = new Nano11Target(s, s.Mount, s.Image.Architecture);
+ s.Log("Nano11: this stage applies the plan, not the individual removal groups; the groups are Core's.");
+ s.Log("Nano11: the output is not serviceable. Windows Update, recovery, Defender and component servicing are removed.");
+ await CleanComponentsAsync(s, token).ConfigureAwait(false);
+ await RemoveNano11AppsAsync(target, token).ConfigureAwait(false);
+ await RemoveNano11PackagesAsync(target, token).ConfigureAwait(false);
+ await s.Tracking.RunAsync("nano:files", NanoStage, "Remove Nano11 payloads, drivers, fonts and services", () =>
+ {
+ Nano11Files.Apply(target.Mount, s.Log, s.Recipe.TurboMode);
+ Nano11Files.RemoveServices(target.Mount, s.Log);
+ return Task.CompletedTask;
+ }).ConfigureAwait(false);
+ await ReplaceNano11ComponentStoreAsync(s, target, token).ConfigureAwait(false);
+ s.Log("Nano11: reductions applied. Test this image in an isolated VM; it is not a Windows 11 replacement.");
+ }
+
+ private static async Task RemoveNano11AppsAsync(Nano11Target target, CancellationToken token)
+ {
+ var s = target.Session;
+ var output = await s.Dism.RunAsync(token, $"/Image:{target.Mount}", "/Get-ProvisionedAppxPackages").ConfigureAwait(false);
+ var plan = Nano11Plan.AppFragments;
+ var doomed = DismClient.ParseApps(output)
+ .Where(app => plan.Any(fragment => app.PackageName.Contains(fragment, StringComparison.OrdinalIgnoreCase)))
+ .DistinctBy(app => app.PackageName).ToArray();
+ if (doomed.Length == 0)
+ {
+ s.Tracking.Skip("nano:apps", NanoStage, "Remove Nano11 provisioned apps", "No matching provisioned app in this image");
+ return;
+ }
+ foreach (var app in doomed)
+ {
+ token.ThrowIfCancellationRequested();
+ try
+ {
+ await s.Tracking.RunAsync("nano:app:" + app.PackageName, NanoStage, $"Remove Nano11 app: {app.DisplayName}",
+ () => s.Dism.RunAsync(token, $"/Image:{target.Mount}", "/Remove-ProvisionedAppxPackage",
+ $"/PackageName:{app.PackageName}")).ConfigureAwait(false);
+ }
+ catch (DismCommandException error)
+ {
+ // A refused app is recorded as failed and reported; the rest of the plan still runs.
+ s.Warn($"Nano11 could not unregister {app.DisplayName} ({app.PackageName}): exit {error.ExitCode}. " +
+ "The remaining reductions still run; any leftover folder is removed with the payloads.");
+ }
+ }
+ }
+
+ private static async Task RemoveNano11PackagesAsync(Nano11Target target, CancellationToken token)
+ {
+ var s = target.Session;
+ var families = Nano11Plan.FeatureIdentities(target.Architecture);
+ static bool Matches(string identity, IReadOnlyList plan) =>
+ plan.Any(family => identity.StartsWith(family, StringComparison.OrdinalIgnoreCase));
+ var packages = ImageInventory.ParseIdentityStates(
+ await s.Dism.RunAsync(token, $"/Image:{target.Mount}", "/Get-Packages").ConfigureAwait(false),
+ "Package Identity", ImageItemKind.Package)
+ .Where(item => Matches(item.Identity, families)).ToArray();
+ var capabilities = ImageInventory.ParseIdentityStates(
+ await s.Dism.RunAsync(token, $"/Image:{target.Mount}", "/Get-Capabilities").ConfigureAwait(false),
+ "Capability Identity", ImageItemKind.Capability)
+ .Where(item => Matches(item.Identity, families)).ToArray();
+ if (packages.Length == 0 && capabilities.Length == 0)
+ {
+ s.Tracking.Skip("nano:packages", NanoStage, "Remove Nano11 packages and capabilities",
+ "No matching package or capability in this image");
+ return;
+ }
+ foreach (var package in packages)
+ {
+ token.ThrowIfCancellationRequested();
+ try
+ {
+ await s.Tracking.RunAsync("nano:package:" + package.Identity, NanoStage, $"Remove Nano11 package: {package.Identity}",
+ () => s.Dism.RunAsync(token, $"/Image:{target.Mount}", "/Remove-Package",
+ $"/PackageName:{package.Identity}", "/NoRestart")).ConfigureAwait(false);
+ }
+ catch (DismCommandException error)
+ {
+ // Protected packages refuse removal. Nano11 records the truth and keeps going; the payload work still applies.
+ s.Warn($"Nano11 could not remove package {package.Identity}: exit {error.ExitCode}. Its component files are " +
+ "removed only if the component-store replacement keeps no family that needs them.");
+ }
+ }
+ if (capabilities.Length == 0) return;
+ var names = capabilities.Select(capability => capability.Identity).ToArray();
+ await s.Tracking.RunBatchAsync(names.Select(name => ("nano:capability:" + name, $"Remove Nano11 capability: {name}")).ToArray(),
+ NanoStage, async () => { await s.Dism.RemoveCapabilitiesAsync(target.Mount, names, token).ConfigureAwait(false); },
+ "capabilities").ConfigureAwait(false);
+ }
+
+ ///
+ /// Replace the image's component store with only the families Nano11 keeps. The retained folders are copied into a
+ /// sibling folder inside the offline image and swapped in, so a failure before the swap leaves WinSxS intact.
+ ///
+ private static async Task ReplaceNano11ComponentStoreAsync(BuildSession s, Nano11Target target, CancellationToken token)
+ {
+ var store = Path.Combine(target.Mount, @"Windows\WinSxS");
+ var temporary = Path.Combine(target.Mount, @"Windows\WinSxS_nano11");
+ if (!Directory.Exists(store))
+ throw new InvalidDataException("Nano11 cannot find this image's component store. No component payloads were pruned.");
+ PathSafety.RejectReparsePoints(store);
+ if (Directory.Exists(temporary)) ImageOperations.DeleteTree(temporary, s.Recipe.TurboMode);
+ var directories = Directory.EnumerateDirectories(store)
+ .ToDictionary(path => Path.GetFileName(path), path => path, StringComparer.OrdinalIgnoreCase);
+ var wanted = Nano11Plan.RetainedStoreFamilies(target.Architecture);
+ var missing = wanted.Where(family => !directories.Keys.Any(name => name.StartsWith(family, StringComparison.OrdinalIgnoreCase))).ToArray();
+ // The runtime and servicing families are what keep the image able to start and to run its own servicing stack.
+ // Without them this is not a smaller Windows but an unbootable one, so Nano11 refuses instead of guessing.
+ if (missing.Length > 0)
+ throw new InvalidDataException($"Nano11 cannot identify {missing.Length} required {target.Architecture} component " +
+ $"famil{(missing.Length == 1 ? "y" : "ies")} in this image ({string.Join(", ", missing.Take(6))}" +
+ (missing.Length > 6 ? ", ..." : "") + "). No component payloads were pruned and the image is unchanged.");
+
+ await s.Tracking.RunAsync("nano:winsxs", NanoStage, "Replace the component store with only the retained families", () =>
+ {
+ token.ThrowIfCancellationRequested();
+ Directory.CreateDirectory(temporary);
+ long bytes = 0;
+ var copied = 0;
+ foreach (var (name, path) in directories.Where(pair => wanted.Any(family =>
+ pair.Key.StartsWith(family, StringComparison.OrdinalIgnoreCase))))
+ {
+ bytes += CopyTree(path, Path.Combine(temporary, name));
+ copied++;
+ s.Log($"Nano11: retained component family {name}");
+ }
+ foreach (var metadata in new[] { "Catalogs", "FileMaps", "Fusion", "InstallTemp", "Manifests", "SettingsManifests", "Temp" })
+ {
+ var path = Path.Combine(store, metadata);
+ if (!Directory.Exists(path)) continue;
+ bytes += CopyTree(path, Path.Combine(temporary, metadata));
+ copied++;
+ }
+ if (copied == 0) throw new InvalidDataException("Nano11 copied no component families; the image was left unchanged.");
+ s.Log($"Nano11: {directories.Count} store folders replaced by {copied} retained folders ({bytes:N0} bytes).");
+ // The swap is the point of no return for the component store; it happens only after everything was copied.
+ ImageOperations.DeleteTree(store, s.Recipe.TurboMode);
+ Directory.Move(temporary, store);
+ return Task.CompletedTask;
+ }, () => "Component servicing is removed for this image; the original store was deleted after the retained families were copied.").ConfigureAwait(false);
+ s.Log("Nano11: component store replaced with the retained runtime and servicing families.");
+ }
+
+ /// Copies a folder tree and returns the number of bytes copied.
+ private static long CopyTree(string source, string destination)
+ {
+ Directory.CreateDirectory(destination);
+ long bytes = 0;
+ foreach (var file in Directory.EnumerateFiles(source))
+ {
+ var target = Path.Combine(destination, Path.GetFileName(file));
+ if (File.Exists(target)) File.SetAttributes(target, FileAttributes.Normal);
+ File.Copy(file, target, overwrite: true);
+ bytes += new FileInfo(target).Length;
+ }
+ foreach (var directory in Directory.EnumerateDirectories(source))
+ bytes += CopyTree(directory, Path.Combine(destination, Path.GetFileName(directory)));
+ return bytes;
+ }
+}
diff --git a/src/Tiny11Builder.Core/BuildEngine.cs b/src/Tiny11Builder.Core/BuildEngine.cs
index c0340471..ce5005ce 100644
--- a/src/Tiny11Builder.Core/BuildEngine.cs
+++ b/src/Tiny11Builder.Core/BuildEngine.cs
@@ -121,6 +121,9 @@ void Guard(Action step)
public async Task BuildAsync(BuildRecipe recipe, IProgress? progress, CancellationToken token)
{
var elapsed = Stopwatch.StartNew();
+ // Nano11 exists to produce the smallest ISO, so its output settings are the smallest ones. The recipe that is
+ // written to the job and used for resume is the one that actually ran.
+ if (recipe.Flavor == BuildFlavor.Nano) recipe = recipe.WithSmallestOutput();
PathSafety.Validate(recipe);
WindowsUpdates.ValidateSources(recipe);
if (string.IsNullOrEmpty(recipe.OscdimgPath)) throw new FileNotFoundException("Windows ADK oscdimg.exe is required to create a bootable ISO.");
@@ -139,6 +142,11 @@ public async Task BuildAsync(BuildRecipe recipe, IProgress File.Exists(Path.Combine(media.RootPath, p))) ??
throw new InvalidDataException("The source does not contain a supported UEFI boot image.");
+ // Older media, 21H2 in particular, can omit the .NET 3.5 payload. Refuse before a job or mount exists
+ // rather than stopping after the image has already been serviced for earlier stages.
+ if (recipe.EnableNetFx3 && !MediaManifest.HasNetFx3Payload(media.RootPath))
+ throw new InvalidDataException("This source has no sources\\sxs .NET 3.5 payload, so .NET 3.5 cannot be " +
+ "enabled offline from it. Turn off .NET 3.5 in Build settings, or use media that includes that folder.");
var sourceInstall = new FileInfo(sourceWim);
using var job = BuildJob.Create(recipe.WorkspacePath, "build", execution.BufferedLog);
var staging = Path.Combine(job.Directory, "media");
@@ -194,6 +202,7 @@ public async Task BuildAsync(BuildRecipe recipe, IProgress recipe.EnableNetFx3,
"Component cleanup" => recipe.SelectedOptions.Contains("cleanup") || recipe.Flavor == BuildFlavor.Core,
"Core pruning" => recipe.Flavor == BuildFlavor.Core,
+ "Nano11 reductions" => recipe.Flavor == BuildFlavor.Nano,
"Redundant data" => recipe.RemoveRedundantData,
"Setup image" => SetupInstaller.RequiresBootEdit(recipe),
_ => true
@@ -204,7 +213,9 @@ public async Task BuildAsync(BuildRecipe recipe, IProgress 26100) Log("Newer/Insider builds require matching tools; no boot certification is implied.");
- if (recipe.Flavor == BuildFlavor.Core || recipe.ExpertActions.Length > 0)
+ if (image.IsLegacyRelease) Log($"Windows 11 {WindowsImage.MinimumRelease} media (build {image.Version.Build}) predates the "
+ "22H2 removal plans. Supported items that are absent are logged as not present; verify the result in a VM.");
+ if (recipe.Flavor is BuildFlavor.Core or BuildFlavor.Nano || recipe.ExpertActions.Length > 0)
Log("WARNING: Core/expert output may not boot, update, recover, or provide antivirus protection. Test in an isolated VM.");
Stage("Copy media", "Copying setup media, excluding the original multi-edition installation image.");
session.StagingResult = await MediaStager.CopyAsync(media.RootPath, staging, execution.CopyWorkers,
@@ -393,17 +404,20 @@ await RemoveCapabilitiesAsync(session, removalCapabilities.Select(c => c.Identit
recipe.TurboMode, "Optional features", token).ConfigureAwait(false);
WarnDeferredCapabilities(session);
// DISM refuses cleanup while operations are pending, and .NET 3.5 leaves some until first boot.
- if (recipe.SelectedOptions.Contains("cleanup") || recipe.Flavor == BuildFlavor.Core)
+ if (recipe.SelectedOptions.Contains("cleanup") || recipe.Flavor is BuildFlavor.Core or BuildFlavor.Nano)
{
Stage("Component cleanup", recipe.Flavor == BuildFlavor.Core ?
- "Cleaning and resetting the component base before Core payload pruning." : "Cleaning superseded components without ResetBase.");
+ "Cleaning and resetting the component base before Core payload pruning." :
+ recipe.Flavor == BuildFlavor.Nano ?
+ "Cleaning and resetting the component base before the Nano11 store replacement." :
+ "Cleaning superseded components without ResetBase.");
await CleanComponentsAsync(session, token).ConfigureAwait(false);
}
if (recipe.EnableNetFx3)
{
Stage(".NET 3.5", "Enabling .NET 3.5 from matching source media, without Windows Update.");
var sxs = Path.Combine(media.RootPath, @"sources\sxs");
- if (!Directory.Exists(sxs)) throw new DirectoryNotFoundException("The source has no sources\\sxs payload for .NET 3.5.");
+ if (!MediaManifest.HasNetFx3Payload(media.RootPath)) throw new DirectoryNotFoundException("The source has no sources\\sxs payload for .NET 3.5.");
await dism.RunAsync(token, $"/Image:{mount}", "/Enable-Feature", "/FeatureName:NetFx3", "/All",
"/LimitAccess", $"/Source:{sxs}", "/NoRestart").ConfigureAwait(false);
}
@@ -423,7 +437,10 @@ await tracking.RunAsync("registry:settings", "Windows settings", "Apply and veri
Stage("Core pruning", "Trimming Core component payloads and recovery files.");
imageOperations.TrimCore(mount, image.Architecture, Log, token, recipe.TurboMode);
}
+ // Cross-check the retained families before any Nano11 file is removed, so a wrong image is refused early.
+ if (recipe.Flavor == BuildFlavor.Nano) Nano11Plan.RequireRetainedFamilies(mount, image.Architecture);
imageOperations.ApplyNativeActions(mount, recipe.ExpertActions, Log, recipe.TurboMode);
+ if (recipe.Flavor == BuildFlavor.Nano) await TrimNano11Async(session, token).ConfigureAwait(false);
if (recipe.RemoveRedundantData)
{
Stage("Redundant data", "Removing offline cache, archived logs and crash reports.");
diff --git a/src/Tiny11Builder.Core/BuildExecutionPlan.cs b/src/Tiny11Builder.Core/BuildExecutionPlan.cs
index f3ccd439..9a4f98ad 100644
--- a/src/Tiny11Builder.Core/BuildExecutionPlan.cs
+++ b/src/Tiny11Builder.Core/BuildExecutionPlan.cs
@@ -13,7 +13,7 @@ public static BuildExecutionPlan Create(BuildRecipe recipe, int logicalProcessor
{
if (logicalProcessors < 1) throw new ArgumentOutOfRangeException(nameof(logicalProcessors));
return new(recipe.TurboMode && allowOptimizedMount,
- recipe.TurboMode && (recipe.Flavor == BuildFlavor.Core ||
+ recipe.TurboMode && (recipe.Flavor is BuildFlavor.Core or BuildFlavor.Nano ||
recipe.Compression == Compression.Fast ||
recipe.ExpertActions.Any(a => a.Kind == ImageItemKind.ComponentPayload)),
recipe.TurboMode ? Math.Clamp(logicalProcessors / 2, 4, 8) : 4,
diff --git a/src/Tiny11Builder.Core/CleanupCatalog.cs b/src/Tiny11Builder.Core/CleanupCatalog.cs
index d03ad7b9..8ec8dac2 100644
--- a/src/Tiny11Builder.Core/CleanupCatalog.cs
+++ b/src/Tiny11Builder.Core/CleanupCatalog.cs
@@ -98,6 +98,9 @@ public static string[] ForPreset(CleanupPreset preset) => Options.Where(o => !o.
"language-extras" or "edge-files" or "onedrive-files" or
"hardware-bypass" or "reserved-storage" or "device-encryption")
.Select(o => o.Id).ToArray(),
+ // Nano11 is Core plus its own built-in reductions (apps, features, payloads, component store), which
+ // the engine applies from Nano11Plan rather than from selectable groups. So its group set is Core's.
+ BuildMode.Nano11 => ForMode(BuildMode.Tiny11Core),
BuildMode.Custom => [],
_ => throw new ArgumentOutOfRangeException(nameof(mode))
};
@@ -105,7 +108,10 @@ public static string[] ForPreset(CleanupPreset preset) => Options.Where(o => !o.
public static BuildMode ModeForRecipe(BuildRecipe recipe)
{
if (recipe.Mode is { } mode) return mode;
- var preset = recipe.Flavor == BuildFlavor.Core ? BuildMode.Tiny11Core : BuildMode.Tiny11;
+ var preset = recipe.Flavor switch
+ {
+ BuildFlavor.Core => BuildMode.Tiny11Core, BuildFlavor.Nano => BuildMode.Nano11, _ => BuildMode.Tiny11
+ };
return !recipe.ShrinkBootImage && recipe.ExpertActions.Length == 0 && recipe.IsoSizeLimitBytes is null &&
recipe.SelectedOptions.ToHashSet(StringComparer.Ordinal).SetEquals(ForMode(preset))
? preset : BuildMode.Custom;
diff --git a/src/Tiny11Builder.Core/JobCheckpoint.cs b/src/Tiny11Builder.Core/JobCheckpoint.cs
index 65d84dce..b8a869e2 100644
--- a/src/Tiny11Builder.Core/JobCheckpoint.cs
+++ b/src/Tiny11Builder.Core/JobCheckpoint.cs
@@ -255,6 +255,10 @@ public static void RequireCompleteWim(string path, string description)
internal static class MediaManifest
{
+ /// Whether the media carries the .NET 3.5 payload that /Enable-Feature /Source requires.
+ public static bool HasNetFx3Payload(string root) =>
+ Directory.Exists(Path.Combine(root, @"sources\sxs"));
+
public static IEnumerable Files(string root)
{
foreach (var entry in Directory.EnumerateFileSystemEntries(root))
diff --git a/src/Tiny11Builder.Core/Models.cs b/src/Tiny11Builder.Core/Models.cs
index 6dc8f2da..c2ca359b 100644
--- a/src/Tiny11Builder.Core/Models.cs
+++ b/src/Tiny11Builder.Core/Models.cs
@@ -5,8 +5,9 @@ namespace Tiny11Builder.Core;
public enum Compression { Recovery, Maximum, Fast }
public enum CleanupPreset { Balanced, Minimal, Original, Custom }
-public enum BuildFlavor { Regular, Core }
-public enum BuildMode { Tiny11, Tiny11Core, Custom }
+public enum BuildFlavor { Regular, Core, Nano }
+// Custom stays last: the app maps a combo-box index onto this enum.
+public enum BuildMode { Tiny11, Tiny11Core, Nano11, Custom }
public enum OptionKind { App, Feature, Capability, Policy, File }
public enum PolicyHive { Software, DefaultUser, System }
public enum ImageItemKind { ProvisionedApp, SystemApp, Feature, Capability, Package, Service, ComponentPayload, FilePayload }
@@ -28,17 +29,27 @@ public sealed record WindowsImage(
int Index, string Name, string Description, string Architecture,
Version Version, string Edition, string Installation, long Size)
{
+ /// Windows 11 21H2 (the original release). The oldest build this engine accepts.
+ public const int MinimumBuild = 22000;
+ public const string MinimumRelease = "21H2";
+
public string Summary => $"{Name} | {Architecture} | build {Version.Build}.{Version.Revision}";
- public bool IsSupported => Index > 0 && Size > 0 && Version.Major == 10 && Version.Build >= 22621 &&
+ public bool IsSupported => Index > 0 && Size > 0 && Version.Major == 10 && Version.Build >= MinimumBuild &&
Installation.Equals("Client", StringComparison.OrdinalIgnoreCase) && Architecture is "x64" or "arm64";
+ ///
+ /// 21H2 predates the 22H2 servicing baseline. It needs the same image tools as any other build, so it is supported,
+ /// but it is an older codebase: announce that so callers can set expectations instead of implying certification.
+ ///
+ public bool IsLegacyRelease => IsSupported && Version.Build < 22621;
+
public void Validate()
{
if (!Installation.Equals("Client", StringComparison.OrdinalIgnoreCase))
throw new InvalidDataException("Tiny11 Builder supports Windows 11 client images only. Windows Server images are not supported.");
if (!IsSupported)
throw new InvalidDataException(
- "Choose a Windows 11 client image, build 22621 (22H2) or newer, in x64 or ARM64 format.");
+ $"Choose a Windows 11 client image, build {MinimumBuild} ({MinimumRelease}) or newer, in x64 or ARM64 format.");
}
}
@@ -92,8 +103,8 @@ public void ValidateOptions()
if (SchemaVersion != 1 || !Enum.IsDefined(Compression) || !Enum.IsDefined(Flavor) ||
(Mode is { } mode && !Enum.IsDefined(mode)))
throw new InvalidDataException("This recipe version or compression mode is not supported.");
- if (Flavor == BuildFlavor.Core && !CoreAcknowledged)
- throw new InvalidDataException("Core requires acknowledgement of the loss of updates, recovery and antivirus protection.");
+ if (Flavor is BuildFlavor.Core or BuildFlavor.Nano && !CoreAcknowledged)
+ throw new InvalidDataException("Core and Nano11 require acknowledgement of the loss of updates, recovery and antivirus protection.");
if (ExpertActions is null || ExpertActions.Any(action => action is null) ||
(ExpertActions.Length > 0 && !ExpertAcknowledged))
throw new InvalidDataException("Custom removals require acknowledgement of the risk of an unbootable image.");
@@ -110,8 +121,8 @@ public void ValidateOptions()
"Load the portable extreme recipe, choose your Windows ISO, and use Shrink boot.wim to rebuild its stock installer.");
if (IsoSizeLimitBytes is { } limit && (limit is < 64_000_000 or > 4_000_000_000 || Mode is not (null or BuildMode.Custom)))
throw new InvalidDataException("Custom ISO size limits must be between 64 MB and 4 GB (decimal bytes).");
- if (ShrinkBootImage && Mode is not (null or BuildMode.Custom))
- throw new InvalidDataException("Shrinking boot.wim is a Custom option.");
+ if (ShrinkBootImage && Mode is not (null or BuildMode.Custom or BuildMode.Nano11))
+ throw new InvalidDataException("Shrinking boot.wim is a Custom or Nano11 option.");
if (ImageIndex < 1 || SelectedOptions is null ||
SelectedOptions.Length != SelectedOptions.Distinct(StringComparer.Ordinal).Count())
throw new InvalidDataException("Invalid image index or duplicate cleanup options.");
@@ -130,13 +141,24 @@ public void ValidateOptions()
throw new InvalidDataException($"Unknown cleanup option: {id}");
if (SelectedOptions.Any(NativePayloadOptions.IsSelected) && (!ExpertAcknowledged || Mode is not (null or BuildMode.Custom)))
throw new InvalidDataException("Direct payload groups require Custom and the advanced-risk acknowledgement.");
- if (Mode is BuildMode.Tiny11 or BuildMode.Tiny11Core &&
- (Flavor != (Mode == BuildMode.Tiny11Core ? BuildFlavor.Core : BuildFlavor.Regular) ||
+ if (Mode is BuildMode.Tiny11 or BuildMode.Tiny11Core or BuildMode.Nano11 &&
+ (Flavor != (Mode switch { BuildMode.Tiny11Core => BuildFlavor.Core, BuildMode.Nano11 => BuildFlavor.Nano, _ => BuildFlavor.Regular }) ||
ExpertActions.Length > 0 ||
!SelectedOptions.ToHashSet(StringComparer.Ordinal).SetEquals(CleanupCatalog.ForMode(Mode.Value))))
- throw new InvalidDataException("Use Custom for changes to the Tiny11 or Tiny11 Core removal sets.");
+ throw new InvalidDataException("Use Custom for changes to the Tiny11, Tiny11 Core or Nano11 removal sets.");
}
+ ///
+ /// The smallest settings a mode can use. Nano11 applies all of them automatically, because its purpose is the
+ /// smallest ISO rather than a serviceable one: recovery ESD, no redundant offline data, no staged .NET 3.5 setup
+ /// payload and a rebuilt single-index boot.wim.
+ ///
+ public BuildRecipe WithSmallestOutput() => this with
+ {
+ Compression = Compression.Recovery, RemoveRedundantData = true, OmitNetFx3SetupPayload = true,
+ ShrinkBootImage = true
+ };
+
public static BuildRecipe Read(string path)
{
var recipe = JsonSerializer.Deserialize(File.ReadAllText(path), JsonDefaults.Options)
diff --git a/src/Tiny11Builder.Core/Nano11Files.cs b/src/Tiny11Builder.Core/Nano11Files.cs
new file mode 100644
index 00000000..67b0b441
--- /dev/null
+++ b/src/Tiny11Builder.Core/Nano11Files.cs
@@ -0,0 +1,104 @@
+namespace Tiny11Builder.Core;
+
+///
+/// The Nano11 file half: payloads, driver-store folders, fonts, scheduled tasks and service keys. It is separate from
+/// the engine stage so it runs against a test mount, exactly like the Core and payload paths it mirrors.
+///
+internal static class Nano11Files
+{
+ public static void Apply(string mount, Action log, bool turboMode = false)
+ {
+ foreach (var relative in Nano11Plan.Payloads) RemovePayload(mount, relative, log, turboMode);
+ // The recovery image is replaced by an empty placeholder, as nano11.ps1 does: a missing file makes WinRE look
+ // broken to Setup and Windows, while an empty one reports that recovery is unavailable.
+ var recovery = Path.Combine(mount, @"Windows\System32\Recovery\winre.wim");
+ if (!ImageFileAccess.Exists(recovery))
+ {
+ try
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(recovery)!);
+ using var placeholder = File.Create(recovery);
+ log(@"Nano11: created an empty Recovery\winre.wim placeholder so recovery reports as unavailable.");
+ }
+ catch (Exception error) when (error is IOException or UnauthorizedAccessException)
+ {
+ log($@"Nano11 could not create the empty Recovery\winre.wim placeholder: {error.Message}");
+ }
+ }
+ RemoveMatching(mount, @"Windows\System32\DriverStore\FileRepository", "driver package", log, turboMode,
+ name => Nano11Plan.DriverPrefixes.Any(prefix => name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) ||
+ Nano11Plan.DriverNames.Any(driver => name.StartsWith(driver, StringComparison.OrdinalIgnoreCase)));
+ RemoveMatching(mount, @"Windows\assembly", "precompiled .NET assembly", log, turboMode,
+ name => name.StartsWith("NativeImages_", StringComparison.OrdinalIgnoreCase));
+ var fonts = Path.Combine(mount, @"Windows\Fonts");
+ if (!Directory.Exists(fonts)) log(@"Nano11: no Windows\Fonts folder in this image; fonts were left as they are.");
+ else
+ foreach (var file in Directory.EnumerateFiles(fonts).ToArray())
+ {
+ var name = Path.GetFileName(file);
+ if (Nano11Plan.KeptFontPrefixes.Any(prefix => name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))) continue;
+ RemovePayload(mount, Path.GetRelativePath(mount, file), log, turboMode);
+ }
+ var tasks = Path.Combine(mount, @"Windows\System32\Tasks");
+ foreach (var relative in Nano11Plan.TaskFiles)
+ {
+ var path = Path.GetFullPath(Path.Combine(tasks, relative));
+ if (!PathSafety.IsInside(path, mount)) throw new InvalidDataException("A Nano11 scheduled-task path escaped the offline mount.");
+ RemovePayload(mount, Path.GetRelativePath(mount, path), log, turboMode);
+ }
+ log("Nano11: payload, font, driver-store and scheduled-task removals finished.");
+ }
+
+ /// Deletes the named services from every control set. Audio services are never in the plan.
+ public static void RemoveServices(string mount, Action log)
+ {
+ using var privileges = new ImageOperations.PrivilegeScope();
+ using var hive = OfflineRegistry.Load(Path.Combine(mount, @"Windows\System32\config\SYSTEM"));
+ var root = hive.Root;
+ var removed = 0;
+ foreach (var control in root.GetSubKeyNames().Where(key => System.Text.RegularExpressions.Regex.IsMatch(key, @"^ControlSet\d{3}$")))
+ {
+ using var services = OfflineRegistry.OpenWriteKey(root, control + @"\Services");
+ foreach (var name in Nano11Plan.RemovedServices)
+ {
+ if (!services.GetSubKeyNames().Contains(name, StringComparer.OrdinalIgnoreCase))
+ {
+ log($@"Nano11: not present in {control}: service {name}");
+ continue;
+ }
+ OfflineRegistry.DeleteKeyTree(services, name);
+ removed++;
+ log($@"Nano11: removed service {control}\{name}");
+ }
+ }
+ log(removed == 0 ? "Nano11: no named service existed in this image to remove." :
+ $"Nano11: {removed} service definition(s) removed. Audio services are kept: they are a boot dependency.");
+ }
+
+ private static void RemoveMatching(string mount, string relativeRoot, string what, Action log, bool turboMode,
+ Func match)
+ {
+ var root = Path.Combine(mount, relativeRoot);
+ if (!Directory.Exists(root)) { log($@"Nano11: no {relativeRoot} in this image; no {what} was removed."); return; }
+ foreach (var path in Directory.EnumerateDirectories(root).ToArray())
+ if (match(Path.GetFileName(path))) RemovePayload(mount, Path.GetRelativePath(mount, path), log, turboMode);
+ }
+
+ private static void RemovePayload(string mount, string relative, Action log, bool turboMode)
+ {
+ var path = Path.GetFullPath(Path.Combine(mount, relative));
+ if (!PathSafety.IsInside(path, mount)) throw new InvalidDataException("A Nano11 payload path escaped the offline mount.");
+ if (!ImageFileAccess.Exists(path)) { log($@"Nano11: not present: {relative}"); return; }
+ PathSafety.RejectReparsePoints(Path.GetDirectoryName(path)!);
+ try
+ {
+ ImageOperations.DeleteTree(path, turboMode);
+ log($@"Nano11: removed {relative}");
+ }
+ catch (Exception error) when (error is IOException or UnauthorizedAccessException)
+ {
+ // A payload held by the offline servicing stack is reported, never claimed as removed.
+ log($"Nano11 could not remove {relative}: {error.Message}");
+ }
+ }
+}
diff --git a/src/Tiny11Builder.Core/Nano11Plan.cs b/src/Tiny11Builder.Core/Nano11Plan.cs
new file mode 100644
index 00000000..f8ba9918
--- /dev/null
+++ b/src/Tiny11Builder.Core/Nano11Plan.cs
@@ -0,0 +1,161 @@
+namespace Tiny11Builder.Core;
+
+///
+/// The Nano11 reduction plan, taken from the nano11.ps1 builder. Nano11 is Core plus a much smaller
+/// component store: Core keeps every runtime/servicing family, Nano11 keeps only the families the booted
+/// system needs and drops the rest. Every identity here is optional: a target that is absent from an image
+/// is logged as not present and skipped, never guessed, because package identities differ by build.
+///
+public static class Nano11Plan
+{
+ /// Provisioned-app PackageName fragments removed before servicing.
+ public static IReadOnlyList AppFragments { get; } =
+ [
+ "Zune", "Bing", "Clipchamp", "Gaming", "People", "PowerAutomate", "Teams", "Todos", "YourPhone",
+ "SoundRecorder", "Solitaire", "FeedbackHub", "Maps", "OfficeHub", "Help", "Family", "Alarms",
+ "CommunicationsApps", "Copilot", "CompatibilityEnhancements", "AV1VideoExtension",
+ "AVCEncoderVideoExtension", "HEIFImageExtension", "HEVCVideoExtension", "MicrosoftStickyNotes",
+ "OutlookForWindows", "RawImageExtension", "SecHealthUI", "VP9VideoExtensions", "WebpImageExtension",
+ "DevHome", "Photos", "Camera", "QuickAssist", "CoreAI", "PeopleExperienceHost",
+ "PinningConfirmationDialog", "SecureAssessmentBrowser", "Paint", "Notepad"
+ ];
+
+ /// Optional-feature and capability payloads removed for the image's own architecture.
+ /// The image architecture: x64 or arm64.
+ public static IReadOnlyList FeatureIdentities(string architecture)
+ {
+ var native = architecture.Equals("arm64", StringComparison.OrdinalIgnoreCase) ? "arm64" : "amd64";
+ return
+ [
+ "Microsoft-Windows-InternetExplorer-Optional-Package", "Microsoft-Windows-MediaPlayer-Package",
+ "Microsoft-Windows-WordPad-FoD-Package", "Microsoft-Windows-StepsRecorder-Package",
+ "Microsoft-Windows-MSPaint-FoD-Package", "Microsoft-Windows-SnippingTool-FoD-Package",
+ "Microsoft-Windows-TabletPCMath-Package", "Microsoft-Windows-Xps-Xps-Viewer-Opt-Package",
+ "Microsoft-Windows-PowerShell-ISE-FOD-Package", "OpenSSH-Client-Package",
+ $"Microsoft-Windows-LanguageFeatures-Handwriting-{native}-Package",
+ $"Microsoft-Windows-LanguageFeatures-OCR-{native}-Package",
+ $"Microsoft-Windows-LanguageFeatures-Speech-{native}-Package",
+ $"Microsoft-Windows-LanguageFeatures-TextToSpeech-{native}-Package",
+ "Windows-Defender-Client-Package", "Microsoft-Windows-Search-Engine-Client-Package",
+ "Microsoft-Windows-Kernel-LA57-FoD-Package", "Microsoft-Windows-Hello-Face-Package",
+ "Microsoft-Windows-Hello-BioEnrollment-Package", "Microsoft-Windows-BitLocker-DriveEncryption-FVE-Package",
+ "Microsoft-Windows-TPM-WMI-Provider-Package", "Microsoft-Windows-Narrator-App-Package",
+ "Microsoft-Windows-Magnifier-App-Package", "Microsoft-Windows-Printing-PMCPPC-FoD-Package",
+ "Microsoft-Windows-WebcamExperience-Package", "Microsoft-Media-MPEG2-Decoder-Package",
+ "Microsoft-Windows-Wallpaper-Content-Extended-FoD-Package",
+ "Language.Handwriting", "Language.OCR", "Language.Speech", "Language.TextToSpeech"
+ ];
+ }
+
+ /// Direct payload and file removals (paths are relative to the offline mount).
+ public static IReadOnlyList Payloads { get; } =
+ [
+ @"Program Files (x86)\Microsoft\Edge", @"Program Files (x86)\Microsoft\EdgeCore",
+ @"Program Files (x86)\Microsoft\EdgeUpdate", @"Program Files (x86)\Microsoft\EdgeWebView",
+ @"Windows\System32\Microsoft-Edge-Webview", @"Windows\System32\Recovery\winre.wim",
+ @"Windows\System32\OneDriveSetup.exe", @"Windows\System32\InputMethod\CHS",
+ @"Windows\System32\InputMethod\CHT", @"Windows\System32\InputMethod\JPN",
+ @"Windows\System32\InputMethod\KOR", @"Windows\Web", @"Windows\Help", @"Windows\Cursors",
+ @"Windows\Speech\Engines\TTS", @"ProgramData\Microsoft\Windows Defender\Definition Updates",
+ @"Windows\Temp"
+ ];
+
+ /// Font families kept. Everything else in Windows\Fonts is removed.
+ public static IReadOnlyList KeptFontPrefixes { get; } =
+ [
+ "segoe", "segui", "tahoma", "marlett", "8541oem", "consol", "lucon", "calibri", "arial", "times", "cou",
+ "8"
+ ];
+
+ /// Non-Latin font families removed even when the Windows language matches them.
+ public static IReadOnlyList RemovedFontPrefixes { get; } =
+ ["mingli", "msjh", "msyh", "malgun", "meiryo", "yugoth", "segoeuihistoric"];
+
+ /// Driver-store folders removed: printers, scanners, multi-function devices, smartcards, tape and Bluetooth PAN.
+ public static IReadOnlyList DriverPrefixes { get; } = ["prn", "scan", "mfd"];
+
+ public static IReadOnlyList DriverNames { get; } =
+ ["wscsmd.inf", "tapdrv", "rdpbus.inf", "tdibth.inf"];
+
+ ///
+ /// Component-store families Nano11 keeps. Nano11 replaces the whole WinSxS folder with only these,
+ /// so a missing family is a hard failure rather than a silent skip.
+ ///
+ public static IReadOnlyList RetainedStoreFamilies(string architecture) =>
+ architecture.Equals("arm64", StringComparison.OrdinalIgnoreCase) ?
+ [
+ "arm64_microsoft-windows-servicingstack-onecore", "arm64_microsoft-windows-servicingcommon",
+ "arm64_microsoft-windows-servicing-onecore-uapi", "arm64_microsoft-windows-servicing-adm",
+ "arm64_microsoft-windows-servicingstack", "arm64_microsoft-windows-servicingstack-inetsrv",
+ "arm64_microsoft-windows-servicingstack-msg", "arm64_microsoft.vc80.crt",
+ "arm64_microsoft.vc90.crt", "arm64_microsoft.windows.common-controls",
+ "arm64_microsoft.windows.gdiplus", "arm64_microsoft.windows.c..-controls.resources",
+ "arm64_microsoft.windows.i..utomation.proxystub", "arm64_microsoft.windows.isolationautomation",
+ "x86_microsoft.vc80.crt", "x86_microsoft.vc90.crt", "x86_microsoft.windows.common-controls",
+ "x86_microsoft.windows.gdiplus", "x86_microsoft.windows.c..-controls.resources",
+ "x86_microsoft.windows.i..utomation.proxystub", "x86_microsoft.windows.isolationautomation"
+ ] :
+ [
+ "amd64_microsoft-windows-servicingstack", "amd64_microsoft-windows-servicingstack-onecore",
+ "amd64_microsoft-windows-servicingstack-inetsrv", "amd64_microsoft-windows-servicingstack-msg",
+ "amd64_microsoft-windows-s..stack-inetsrv-extra", "amd64_microsoft-windows-s..stack-msg.resources",
+ "amd64_microsoft-windows-servicingstack-msg", "amd64_microsoft.vc80.crt", "amd64_microsoft.vc90.crt",
+ "amd64_microsoft.windows.common-controls", "amd64_microsoft.windows.gdiplus",
+ "amd64_microsoft.windows.c..-controls.resources", "amd64_microsoft.windows.i..utomation.proxystub",
+ "amd64_microsoft.windows.isolationautomation",
+ "x86_microsoft.vc80.crt", "x86_microsoft.vc90.crt", "x86_microsoft.windows.common-controls",
+ "x86_microsoft.windows.gdiplus", "x86_microsoft.windows.c..-controls.resources",
+ "x86_microsoft.windows.i..utomation.proxystub", "x86_microsoft.windows.isolationautomation",
+ "x86_microsoft-windows-s..ngstack-onecorebase", "x86_microsoft-windows-s..stack-termsrv-extra",
+ "x86_microsoft-windows-servicingstack", "x86_microsoft-windows-servicingstack-inetsrv",
+ "x86_microsoft-windows-servicingstack-onecore"
+ ];
+
+ ///
+ /// Confirms the retained families exist in a mounted image before any Nano11 file is removed. Nano11 replaces the
+ /// whole component store, so an image without these families would be reduced to an unbootable one.
+ ///
+ public static void RequireRetainedFamilies(string mount, string architecture)
+ {
+ var store = Path.Combine(mount, @"Windows\WinSxS");
+ if (!Directory.Exists(store))
+ throw new InvalidDataException("Nano11 cannot find this image's component store. Nothing was removed.");
+ var names = Directory.EnumerateDirectories(store).Select(Path.GetFileName).OfType().ToArray();
+ var missing = RetainedStoreFamilies(architecture)
+ .Where(family => !names.Any(name => name.StartsWith(family, StringComparison.OrdinalIgnoreCase))).ToArray();
+ if (missing.Length == 0) return;
+ throw new InvalidDataException($"Nano11 cannot identify {missing.Length} required {architecture} component " +
+ $"famil{(missing.Length == 1 ? "y" : "ies")} in this image ({string.Join(", ", missing.Take(6))}" +
+ (missing.Length > 6 ? ", ..." : "") + "). The build stopped before any payload was removed.");
+ }
+
+ /// Services deleted from every control set. Audio services are excluded: they are a known boot hazard.
+ public static IReadOnlyList RemovedServices { get; } =
+ [
+ "Spooler", "PrintNotify", "Fax", "RemoteRegistry", "diagsvc", "WerSvc", "PcaSvc", "MapsBroker",
+ "WalletService", "BthAvctpSvc", "BluetoothUserService", "wuauserv", "UsoSvc", "WaaSMedicSvc"
+ ];
+
+ /// Defender services switched off rather than deleted.
+ public static IReadOnlyList DisabledServices { get; } =
+ ["WinDefend", "WdNisSvc", "WdNisDrv", "WdFilter", "Sense", "dmwappushservice"];
+
+ /// Scheduled-task definition files removed from Windows\System32\Tasks.
+ public static IReadOnlyList TaskFiles { get; } =
+ [
+ @"Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser",
+ @"Microsoft\Windows\Application Experience\ProgramDataUpdater",
+ @"Microsoft\Windows\Customer Experience Improvement Program",
+ @"Microsoft\Windows\Chkdsk\Proxy", @"Microsoft\Windows\Windows Error Reporting\QueueReporting"
+ ];
+
+ /// Extra offline registry values written only for Nano11.
+ public static IReadOnlyList Policies { get; } =
+ [
+ // Prevent Dev Home and new Outlook from being installed after first sign-in.
+ new(PolicyHive.Software, @"Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\OutlookUpdate", "workCompleted", 1),
+ new(PolicyHive.Software, @"Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\DevHomeUpdate", "workCompleted", 1),
+ // Windows Update is already disabled by the Core policies; this also hides its settings page.
+ new(PolicyHive.Software, @"Microsoft\Windows\CurrentVersion\Policies\Explorer", "SettingsPageVisibility", "hide:virus;windowsupdate")
+ ];
+}
diff --git a/src/Tiny11Builder.Core/OfflineRegistry.cs b/src/Tiny11Builder.Core/OfflineRegistry.cs
index 4bb6ea85..de20ffab 100644
--- a/src/Tiny11Builder.Core/OfflineRegistry.cs
+++ b/src/Tiny11Builder.Core/OfflineRegistry.cs
@@ -37,18 +37,22 @@ public void Apply(string mountDirectory, BuildRecipe recipe, Action log)
value.Key.Replace("{ControlSet}", controlSet, StringComparison.Ordinal), value.Name, value.Value, log);
if (recipe.PreferLocalAccount)
Set(software, @"Microsoft\Windows\CurrentVersion\OOBE", "BypassNRO", 1, log);
- if (recipe.Flavor == BuildFlavor.Core)
+ if (recipe.Flavor is BuildFlavor.Core or BuildFlavor.Nano)
{
foreach (var control in system.GetSubKeyNames().Where(key =>
System.Text.RegularExpressions.Regex.IsMatch(key, @"^ControlSet\d{3}$")))
{
using var services = OpenWriteKey(system, control + @"\Services");
var names = services.GetSubKeyNames().ToHashSet(StringComparer.OrdinalIgnoreCase);
- foreach (var name in new[] { "wuauserv", "UsoSvc", "WaaSMedicSvc", "WinDefend", "WdNisSvc", "WdNisDrv", "WdFilter", "Sense" })
+ // Nano11 additionally switches off Defender's driver/telemetry services, as its builder does.
+ var services = recipe.Flavor == BuildFlavor.Nano ?
+ ["wuauserv", "UsoSvc", "WaaSMedicSvc", .. Nano11Plan.DisabledServices] :
+ ["wuauserv", "UsoSvc", "WaaSMedicSvc", "WinDefend", "WdNisSvc", "WdNisDrv", "WdFilter", "Sense"];
+ foreach (var name in services)
{
if (!names.Contains(name)) { log($"Not present in {control}: service {name}"); continue; }
Set(system, $@"{control}\Services\{name}", "Start", 4, log);
- log($"Core: disabled service {control}\\{name}");
+ log($"Disabled service {control}\\{name}");
}
}
Set(software, @"Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", 1, log);
@@ -56,6 +60,10 @@ public void Apply(string mountDirectory, BuildRecipe recipe, Action log)
Set(software, @"Policies\Microsoft\Windows Defender", "DisableAntiSpyware", 1, log);
Set(software, @"Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", 1, log);
}
+ if (recipe.Flavor == BuildFlavor.Nano)
+ foreach (var value in Nano11Plan.Policies)
+ Set(value.Hive switch { PolicyHive.Software => software, PolicyHive.DefaultUser => user, _ => system },
+ value.Key.Replace("{ControlSet}", controlSet, StringComparison.Ordinal), value.Name, value.Value, log);
}
public void ApplySetupBypass(string mountDirectory, Action log)
diff --git a/src/Tiny11Builder.Core/PendingOperations.cs b/src/Tiny11Builder.Core/PendingOperations.cs
index a9c3fe01..0732225d 100644
--- a/src/Tiny11Builder.Core/PendingOperations.cs
+++ b/src/Tiny11Builder.Core/PendingOperations.cs
@@ -26,7 +26,7 @@ public static async Task ScanAsync(DismClient dism, string mount, C
public static bool IsPending(string state) =>
Regex.Replace(state, @"\s+", " ").Trim().EndsWith("pending", StringComparison.OrdinalIgnoreCase);
- public static string Refusal(BuildRecipe recipe) => (recipe.Flavor == BuildFlavor.Core ?
+ public static string Refusal(BuildRecipe recipe) => (recipe.Flavor is BuildFlavor.Core or BuildFlavor.Nano ?
"Core stopped before trimming any component: the image has pending operations, and Core would delete the files needed to finish them at first boot. " :
"Component payloads were not removed: the image has pending operations, and removing payloads would delete the files needed to finish them at first boot. ") +
"Build without .NET 3.5, or build a serviceable Tiny11, which keeps those files. Pending actions are never reverted.";
diff --git a/src/Tiny11Builder.Core/SetupInstaller.cs b/src/Tiny11Builder.Core/SetupInstaller.cs
index 49947642..8931d54f 100644
--- a/src/Tiny11Builder.Core/SetupInstaller.cs
+++ b/src/Tiny11Builder.Core/SetupInstaller.cs
@@ -4,7 +4,8 @@ namespace Tiny11Builder.Core;
public static class SetupInstaller
{
- public static bool RequiresLegacy(BuildRecipe recipe) => recipe.Flavor == BuildFlavor.Core || recipe.SelectedOptions.Any(NativePayloadOptions.IsSelected) ||
+ public static bool RequiresLegacy(BuildRecipe recipe) => recipe.Flavor is BuildFlavor.Core or BuildFlavor.Nano ||
+ recipe.SelectedOptions.Any(NativePayloadOptions.IsSelected) ||
recipe.ExpertActions.Any(action => action.Kind is ImageItemKind.ComponentPayload or ImageItemKind.FilePayload && action.Mode == ExpertActionMode.Remove);
internal static bool RequiresBootEdit(BuildRecipe recipe) =>
diff --git a/tests/Tiny11Builder.Core.Tests/BuildEngineTests.cs b/tests/Tiny11Builder.Core.Tests/BuildEngineTests.cs
index b4f70c9f..e2c6de83 100644
--- a/tests/Tiny11Builder.Core.Tests/BuildEngineTests.cs
+++ b/tests/Tiny11Builder.Core.Tests/BuildEngineTests.cs
@@ -10,6 +10,7 @@ namespace Tiny11Builder.Core.Tests;
public sealed class BuildEngineTests
{
[Theory]
+ [InlineData(22000, "arm64", Compression.Recovery)]
[InlineData(22621, "x64", Compression.Recovery)]
[InlineData(22631, "arm64", Compression.Maximum)]
[InlineData(26300, "x64", Compression.Recovery)]
@@ -35,6 +36,72 @@ public async Task Pipeline_exports_selected_edition_uses_actual_build_and_keeps_
Assert.Equal("completed", JsonSerializer.Deserialize(File.ReadAllText(Path.Combine(result.WorkDirectory, "job.json")), JsonDefaults.Options)!.Status);
}
+ [Theory]
+ [InlineData(22000)]
+ [InlineData(22621)]
+ public async Task Requesting_netfx3_from_media_without_the_payload_is_refused_before_anything_changes(int build)
+ {
+ using var fixture = new BuildFixture(build);
+ var messages = new List();
+ var error = await Assert.ThrowsAsync(() => fixture.Engine.BuildAsync(
+ fixture.Recipe with { EnableNetFx3 = true }, new ImmediateProgress(messages.Add), CancellationToken.None));
+ Assert.Contains("sources", error.Message);
+ Assert.Contains("Turn off .NET 3.5", error.Message);
+ // Refused before a job, mount or staging copy existed, so no stage had already run.
+ Assert.DoesNotContain(fixture.Runner.Calls, c => c.Contains("/Mount-Image"));
+ Assert.DoesNotContain(messages, m => m.Stage == "Copy media");
+ }
+
+ [Fact]
+ public async Task Media_that_carries_the_netfx3_payload_still_enables_it()
+ {
+ using var fixture = new BuildFixture(22000);
+ var sxs = Path.Combine(fixture.Source, "sources", "sxs");
+ Directory.CreateDirectory(sxs);
+ File.WriteAllText(Path.Combine(sxs, "netfx3.cab"), "fixture");
+ var result = await fixture.Engine.BuildAsync(fixture.Recipe with { EnableNetFx3 = true }, null, CancellationToken.None);
+ Assert.True(File.Exists(result.IsoPath));
+ Assert.Contains(fixture.Runner.Calls, c => c.Contains("/Enable-Feature") && c.Contains("/FeatureName:NetFx3"));
+ }
+
+ [Fact]
+ public async Task Twenty_one_H_two_media_can_be_added_and_offers_its_editions_for_selection()
+ {
+ using var fixture = new BuildFixture(22000);
+ var images = await fixture.Engine.InspectAsync(fixture.Source, fixture.Recipe.DismPath, CancellationToken.None);
+ var image = Assert.Single(images);
+ Assert.Equal(22000, image.Version.Build);
+ Assert.True(image.IsSupported);
+ Assert.True(image.IsLegacyRelease);
+ image.Validate();
+ // The picker defaults to the first usable edition; nothing filters 21H2 media out.
+ Assert.Equal(0, ImageDefaults.SelectPosition(images));
+ }
+
+ [Fact]
+ public async Task Twenty_one_H_two_builds_end_to_end_and_is_announced_as_an_older_codebase()
+ {
+ using var fixture = new BuildFixture(22000);
+ var messages = new List();
+ var result = await fixture.Engine.BuildAsync(fixture.Recipe,
+ new ImmediateProgress(messages.Add), CancellationToken.None);
+ Assert.True(File.Exists(result.IsoPath));
+ Assert.Contains(messages, m => m.Message.Contains("21H2") && m.Message.Contains("22000") &&
+ m.Message.Contains("predates the 22H2 removal plans"));
+ Assert.Contains(fixture.Runner.Calls, c => c.Contains("/Export-Image") && c.Contains("/SourceIndex:3"));
+ }
+
+ [Fact]
+ public async Task Twenty_one_H_two_refuses_to_build_below_the_21H2_floor_without_touching_the_source()
+ {
+ using var fixture = new BuildFixture(21999);
+ var original = File.ReadAllBytes(Path.Combine(fixture.Source, @"sources\install.wim"));
+ await Assert.ThrowsAsync(() =>
+ fixture.Engine.BuildAsync(fixture.Recipe, null, CancellationToken.None));
+ Assert.Equal(original, File.ReadAllBytes(Path.Combine(fixture.Source, @"sources\install.wim")));
+ Assert.DoesNotContain(fixture.Runner.Calls, c => c.Contains("/Mount-Image"));
+ }
+
[Fact]
public async Task Core_finishes_all_servicing_before_pruning_and_requires_no_servicing_afterward()
{
diff --git a/tests/Tiny11Builder.Core.Tests/CompatibilityTests.cs b/tests/Tiny11Builder.Core.Tests/CompatibilityTests.cs
index 47f55066..5822a525 100644
--- a/tests/Tiny11Builder.Core.Tests/CompatibilityTests.cs
+++ b/tests/Tiny11Builder.Core.Tests/CompatibilityTests.cs
@@ -10,6 +10,8 @@ namespace Tiny11Builder.Core.Tests;
public sealed class CompatibilityTests
{
[Theory]
+ [InlineData(22000, "x64")]
+ [InlineData(22000, "arm64")]
[InlineData(22621, "x64")]
[InlineData(22621, "arm64")]
[InlineData(22631, "x64")]
@@ -19,16 +21,43 @@ public sealed class CompatibilityTests
[InlineData(28000, "x64")]
[InlineData(29689, "arm64")]
[InlineData(99999, "x64")]
- public void Accepts_22H2_through_newer_and_Canary_without_an_upper_limit(int build, string architecture) =>
+ public void Accepts_21H2_through_newer_and_Canary_without_an_upper_limit(int build, string architecture) =>
Image(build, architecture).Validate();
[Theory]
- [InlineData(22000, "x64", "Client")]
+ [InlineData(19045, "x64", "Client")]
+ [InlineData(21999, "x64", "Client")]
[InlineData(22621, "x86", "Client")]
[InlineData(29689, "arm64", "Server")]
public void Rejects_non_supported_image_families(int build, string architecture, string installation) =>
Assert.Throws(() => (Image(build, architecture) with { Installation = installation }).Validate());
+ [Fact]
+ public void Minimum_release_is_21H2_and_21H2_is_flagged_as_a_legacy_release()
+ {
+ Assert.Equal(22000, WindowsImage.MinimumBuild);
+ Assert.Equal("21H2", WindowsImage.MinimumRelease);
+ Assert.True(Image(22000).IsLegacyRelease);
+ Assert.True(Image(22621).IsSupported);
+ Assert.False(Image(22621).IsLegacyRelease);
+ Assert.False(Image(21999).IsLegacyRelease);
+ var error = Assert.Throws(() => Image(21999).Validate());
+ Assert.Contains("21H2", error.Message);
+ Assert.Contains("22000", error.Message);
+ }
+
+ [Theory]
+ [InlineData(22000)]
+ [InlineData(22621)]
+ [InlineData(26100)]
+ public void Supported_builds_are_unchanged_by_the_lower_floor(int build)
+ {
+ var image = Image(build);
+ image.Validate();
+ Assert.True(image.IsSupported);
+ Assert.Equal(build, image.Version.Build);
+ }
+
[Fact]
public void Parses_actual_build_revision_and_empty_description()
{
@@ -111,12 +140,13 @@ public void Unattend_is_architecture_correct_single_index_without_accounts_or_eu
[Fact]
public void Build_modes_have_exact_original_core_and_empty_custom_removal_sets()
{
- Assert.Equal(3, Enum.GetValues().Length);
+ Assert.Equal(4, Enum.GetValues().Length);
Assert.Equal(CleanupCatalog.ForPreset(CleanupPreset.Original), CleanupCatalog.ForMode(BuildMode.Tiny11));
var core = CleanupCatalog.Options.Where(o => o.Minimal || o.Id is
"language-extras" or "edge-files" or "onedrive-files" or
"hardware-bypass" or "reserved-storage" or "device-encryption").Select(o => o.Id).ToArray();
Assert.Equal(core, CleanupCatalog.ForMode(BuildMode.Tiny11Core));
+ Assert.Equal(CleanupCatalog.ForMode(BuildMode.Tiny11Core), CleanupCatalog.ForMode(BuildMode.Nano11));
Assert.Empty(CleanupCatalog.ForMode(BuildMode.Custom));
Assert.Throws(() => CleanupCatalog.ForMode((BuildMode)99));
}
@@ -124,6 +154,7 @@ public void Build_modes_have_exact_original_core_and_empty_custom_removal_sets()
[Theory]
[InlineData(BuildMode.Tiny11, BuildFlavor.Regular)]
[InlineData(BuildMode.Tiny11Core, BuildFlavor.Core)]
+ [InlineData(BuildMode.Nano11, BuildFlavor.Nano)]
public void Fixed_modes_require_their_exact_removals_and_flavor(BuildMode mode, BuildFlavor flavor)
{
var recipe = new BuildRecipe
@@ -134,7 +165,7 @@ public void Fixed_modes_require_their_exact_removals_and_flavor(BuildMode mode,
recipe.ValidateOptions();
Assert.Throws(() => (recipe with { SelectedOptions = [] }).ValidateOptions());
Assert.Throws(() => (recipe with
- { Flavor = flavor == BuildFlavor.Core ? BuildFlavor.Regular : BuildFlavor.Core }).ValidateOptions());
+ { Flavor = flavor == BuildFlavor.Regular ? BuildFlavor.Core : BuildFlavor.Regular }).ValidateOptions());
Assert.Throws(() => (recipe with
{
ExpertAcknowledged = true,
@@ -162,6 +193,8 @@ public void Legacy_recipes_infer_modes_without_changing_custom_core_choices()
{ SelectedOptions = CleanupCatalog.ForMode(BuildMode.Tiny11) }));
Assert.Equal(BuildMode.Tiny11Core, CleanupCatalog.ModeForRecipe(new()
{ Flavor = BuildFlavor.Core, SelectedOptions = CleanupCatalog.ForMode(BuildMode.Tiny11Core) }));
+ Assert.Equal(BuildMode.Nano11, CleanupCatalog.ModeForRecipe(new()
+ { Flavor = BuildFlavor.Nano, SelectedOptions = CleanupCatalog.ForMode(BuildMode.Nano11) }));
var modifiedCore = new BuildRecipe { Flavor = BuildFlavor.Core, SelectedOptions = ["camera"] };
Assert.Equal(BuildMode.Custom, CleanupCatalog.ModeForRecipe(modifiedCore));
Assert.Equal(BuildFlavor.Core, modifiedCore.Flavor);
@@ -193,6 +226,8 @@ public void Custom_mode_recipe_round_trip_preserves_mode_options_and_core()
public void Core_and_expert_actions_require_explicit_acknowledgement()
{
Assert.Throws(() => new BuildRecipe { Flavor = BuildFlavor.Core }.ValidateOptions());
+ Assert.Throws(() => new BuildRecipe { Flavor = BuildFlavor.Nano }.ValidateOptions());
+ new BuildRecipe { Flavor = BuildFlavor.Nano, CoreAcknowledged = true }.ValidateOptions();
Assert.Throws(() => new BuildRecipe
{ ExpertActions = [new(ImageItemKind.Service, "BootCriticalDriver", ExpertActionMode.Remove)] }.ValidateOptions());
new BuildRecipe { Flavor = BuildFlavor.Core, CoreAcknowledged = true, ExpertAcknowledged = true,
diff --git a/tests/Tiny11Builder.Core.Tests/Nano11Tests.cs b/tests/Tiny11Builder.Core.Tests/Nano11Tests.cs
new file mode 100644
index 00000000..9aba808e
--- /dev/null
+++ b/tests/Tiny11Builder.Core.Tests/Nano11Tests.cs
@@ -0,0 +1,187 @@
+using System.Runtime.Versioning;
+using System.Text.Json;
+using Tiny11Builder.Core;
+using Xunit;
+
+namespace Tiny11Builder.Core.Tests;
+
+[SupportedOSPlatform("windows")]
+public sealed class Nano11Tests
+{
+ private static BuildRecipe Recipe(BuildFixture fixture) => fixture.Recipe with
+ {
+ Mode = BuildMode.Nano11, Flavor = BuildFlavor.Nano, CoreAcknowledged = true,
+ SelectedOptions = CleanupCatalog.ForMode(BuildMode.Nano11)
+ };
+
+ [Fact]
+ public void Nano11_is_its_own_mode_with_core_removals_and_a_required_acknowledgement()
+ {
+ Assert.Equal(BuildMode.Nano11, (BuildMode)2);
+ Assert.Equal(BuildMode.Custom, (BuildMode)3); // the app maps a combo index to this enum
+ Assert.Equal(CleanupCatalog.ForMode(BuildMode.Tiny11Core), CleanupCatalog.ForMode(BuildMode.Nano11));
+ Assert.Throws(() => new BuildRecipe { Mode = BuildMode.Nano11, Flavor = BuildFlavor.Nano }.ValidateOptions());
+ new BuildRecipe
+ {
+ Mode = BuildMode.Nano11, Flavor = BuildFlavor.Nano, CoreAcknowledged = true,
+ SelectedOptions = CleanupCatalog.ForMode(BuildMode.Nano11)
+ }.ValidateOptions();
+ // A Nano11 recipe cannot be quietly turned into Core or Custom.
+ Assert.Throws(() => new BuildRecipe
+ {
+ Mode = BuildMode.Nano11, Flavor = BuildFlavor.Core, CoreAcknowledged = true,
+ SelectedOptions = CleanupCatalog.ForMode(BuildMode.Nano11)
+ }.ValidateOptions());
+ Assert.Throws(() => new BuildRecipe
+ {
+ Mode = BuildMode.Nano11, Flavor = BuildFlavor.Nano, CoreAcknowledged = true,
+ SelectedOptions = ["camera"]
+ }.ValidateOptions());
+ }
+
+ [Fact]
+ public void Nano11_needs_the_legacy_installer_and_the_turbo_intermediate_compression_like_core()
+ {
+ var recipe = new BuildRecipe { Flavor = BuildFlavor.Nano, CoreAcknowledged = true };
+ Assert.True(SetupInstaller.RequiresLegacy(recipe));
+ Assert.True(SetupInstaller.RequiresBootEdit(recipe));
+ var turbo = recipe with { TurboMode = true };
+ Assert.True(BuildExecutionPlan.Create(turbo, 8).FastWorkingImage);
+ Assert.StartsWith("Core stopped before trimming any component", PendingOperations.Refusal(recipe));
+ }
+
+ [Fact]
+ public void Nano11_plan_is_architecture_aware_and_still_ships_families_for_both_architectures()
+ {
+ var x64 = Nano11Plan.RetainedStoreFamilies("x64");
+ var arm64 = Nano11Plan.RetainedStoreFamilies("arm64");
+ Assert.Contains("amd64_microsoft-windows-servicingstack", x64);
+ Assert.Contains("arm64_microsoft-windows-servicingstack", arm64);
+ Assert.DoesNotContain("amd64_microsoft-windows-servicingstack", arm64);
+ // 32-bit compatibility payloads are kept on both, because Windows keeps them too.
+ foreach (var families in new[] { x64, arm64 })
+ {
+ Assert.Contains("x86_microsoft.vc80.crt", families);
+ Assert.Contains("x86_microsoft.windows.common-controls", families);
+ }
+ Assert.Contains("Handwriting", string.Join(" ", Nano11Plan.FeatureIdentities("x64")).Replace("amd64", "x64"), StringComparison.Ordinal);
+ Assert.Contains("LanguageFeatures-OCR-arm64-Package", string.Join(" ", Nano11Plan.FeatureIdentities("arm64")));
+ // Audio services are never deleted: the plan must not name them.
+ Assert.DoesNotContain("Audiosrv", Nano11Plan.RemovedServices);
+ Assert.DoesNotContain("AudioEndpointBuilder", Nano11Plan.RemovedServices);
+ }
+
+ [Fact]
+ public async Task Nano11_stage_runs_in_order_after_native_actions_and_replaces_the_component_store()
+ {
+ using var fixture = new BuildFixture();
+ var messages = new List();
+ await fixture.Engine.BuildAsync(Recipe(fixture), new ImmediateProgress(messages.Add), CancellationToken.None);
+ Assert.Contains(messages, m => m.Stage == "Nano11 reductions");
+ // Core pruning never runs for Nano11: the component-store replacement supersedes it.
+ Assert.DoesNotContain(fixture.Events, e => e == "TrimCore");
+ // The component base is reset before the store is replaced, and the swap is the last file work.
+ var reset = fixture.Runner.Calls.FindIndex(c => c.Contains("/ResetBase"));
+ Assert.True(reset >= 0);
+ Assert.Contains(fixture.Runner.Calls, c => c.Contains("/Get-ProvisionedAppxPackages"));
+ Assert.Contains(fixture.Runner.Calls, c => c.Contains("/Remove-ProvisionedAppxPackage"));
+ }
+
+ [Fact]
+ public async Task Nano11_is_recorded_in_the_build_report_as_its_own_flavor()
+ {
+ using var fixture = new BuildFixture { AllowCleanup = false };
+ var result = await fixture.Engine.BuildAsync(Recipe(fixture), null, CancellationToken.None);
+ using var report = JsonDocument.Parse(File.ReadAllText(Path.Combine(result.WorkDirectory, "report.json")));
+ Assert.True(report.RootElement.TryGetProperty("Flavor", out var flavor));
+ Assert.Equal("Nano", flavor.GetString());
+ }
+
+ [Fact]
+ public void Nano11_file_removals_apply_to_a_mount_and_name_what_they_skip()
+ {
+ using var mount = new TempMount();
+ mount.File(@"Windows\Help\help.html");
+ mount.File(@"Windows\Web\wallpaper.jpg");
+ mount.File(@"Windows\Fonts\seguiemj.ttf");
+ mount.File(@"Windows\Fonts\arial.ttf");
+ mount.File(@"Windows\Fonts\malgun.ttf");
+ mount.File(@"Windows\System32\DriverStore\FileRepository\prnms001.inf_x64_neutral_deadbeef\prnms001.inf");
+ mount.File(@"Windows\System32\DriverStore\FileRepository\nvhda.inf_x64_deadbeef\nvhda.inf");
+ mount.File(@"Windows\assembly\NativeImages_v4.0.30319_64\cache.dat");
+ mount.File(@"Windows\System32\Tasks\Microsoft\Windows\Chkdsk\Proxy");
+ var log = new List();
+ Nano11Files.Apply(mount.Root, log.Add);
+
+ Assert.False(File.Exists(mount.Path(@"Windows\Help\help.html")));
+ Assert.False(File.Exists(mount.Path(@"Windows\Web\wallpaper.jpg")));
+ Assert.True(File.Exists(mount.Path(@"Windows\Fonts\seguiemj.ttf"))); // kept by the plan's prefix list
+ Assert.True(File.Exists(mount.Path(@"Windows\Fonts\arial.ttf")));
+ Assert.False(File.Exists(mount.Path(@"Windows\Fonts\malgun.ttf"))); // non-Latin family the plan names
+ Assert.False(Directory.Exists(mount.Path(@"Windows\System32\DriverStore\FileRepository\prnms001.inf_x64_neutral_deadbeef")));
+ Assert.True(Directory.Exists(mount.Path(@"Windows\System32\DriverStore\FileRepository\nvhda.inf_x64_deadbeef")));
+ Assert.False(Directory.Exists(mount.Path(@"Windows\assembly\NativeImages_v4.0.30319_64")));
+ Assert.False(File.Exists(mount.Path(@"Windows\System32\Tasks\Microsoft\Windows\Chkdsk\Proxy")));
+ // The recovery image becomes the empty placeholder the script leaves behind.
+ Assert.True(File.Exists(mount.Path(@"Windows\System32\Recovery\winre.wim")));
+ Assert.Empty(File.ReadAllBytes(mount.Path(@"Windows\System32\Recovery\winre.wim")));
+ Assert.Contains(log, line => line.Contains(@"Nano11: not present: Windows\System32\OneDriveSetup.exe"));
+ }
+
+ [Fact]
+ public void Nano11_recipe_settings_are_the_smallest_ones_available()
+ {
+ var recipe = new BuildRecipe
+ {
+ Mode = BuildMode.Nano11, Flavor = BuildFlavor.Nano, CoreAcknowledged = true,
+ SelectedOptions = CleanupCatalog.ForMode(BuildMode.Nano11)
+ };
+ // The smallest output: recovery ESD, no redundant data, no staged .NET 3.5 payload, rebuilt boot.wim.
+ var smallest = recipe.WithSmallestOutput();
+ Assert.Equal(Compression.Recovery, smallest.Compression);
+ Assert.True(smallest.RemoveRedundantData);
+ Assert.True(smallest.OmitNetFx3SetupPayload);
+ Assert.True(smallest.ShrinkBootImage);
+ smallest.ValidateOptions(); // a shrunk boot.wim is valid for Nano11, not only for Custom
+ Assert.Throws(() => (recipe with { Mode = BuildMode.Tiny11Core, Flavor = BuildFlavor.Core,
+ ShrinkBootImage = true }).ValidateOptions());
+ }
+
+ [Fact]
+ public async Task Nano11_builds_the_smallest_output_even_when_the_recipe_asks_for_larger_settings()
+ {
+ using var fixture = new BuildFixture();
+ var recipe = Recipe(fixture) with
+ {
+ Compression = Compression.Fast, RemoveRedundantData = false, OmitNetFx3SetupPayload = false, ShrinkBootImage = false
+ };
+ await fixture.Engine.BuildAsync(recipe, null, CancellationToken.None);
+ // Fast output, kept redundant data and the .NET 3.5 setup payload are never what Nano11 produces.
+ var compressed = fixture.Runner.Calls.Single(c => c.Contains("/Export-Image") && c.Any(a => a.EndsWith("install.esd")));
+ Assert.Contains("/Compress:recovery", compressed);
+ Assert.Contains(fixture.Runner.Calls, c => c.Contains("/Compress:max")); // the rebuilt boot.wim
+ Assert.DoesNotContain(fixture.Events, e => e == "CleanRedundantData");
+ }
+
+ [Fact]
+ public async Task Fixed_nano11_recipes_refuse_changes_to_the_nano11_removal_set()
+ {
+ using var fixture = new BuildFixture();
+ var recipe = Recipe(fixture) with { SelectedOptions = [.. CleanupCatalog.ForMode(BuildMode.Nano11), "camera"] };
+ await Assert.ThrowsAsync(() => fixture.Engine.BuildAsync(recipe, null, CancellationToken.None));
+ }
+
+internal sealed class TempMount : IDisposable
+{
+ public string Root { get; } = Path.Combine(Path.GetTempPath(), "nano11-mount-" + Guid.NewGuid().ToString("N"));
+ public TempMount() => Directory.CreateDirectory(Root);
+ public string Path(string relative) => System.IO.Path.Combine(Root, relative);
+ public void File(string relative)
+ {
+ var path = Path(relative);
+ Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)!);
+ System.IO.File.WriteAllText(path, "fixture");
+ }
+ public void Dispose() { if (Directory.Exists(Root)) Directory.Delete(Root, recursive: true); }
+}
+}