Skip to content

Remove unused dependencies and add WinUI3Apps hard-link deduplication#46745

Draft
yeelam-gordon wants to merge 2 commits intomicrosoft:mainfrom
yeelam-gordon:dev/gordony/reduce-unused-deps
Draft

Remove unused dependencies and add WinUI3Apps hard-link deduplication#46745
yeelam-gordon wants to merge 2 commits intomicrosoft:mainfrom
yeelam-gordon:dev/gordony/reduce-unused-deps

Conversation

@yeelam-gordon
Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Two related changes to reduce PowerToys installer and installed size by eliminating unused dependencies and deduplicating shared WinAppSDK files.

1. Remove unused dependencies (~11 MB savings per output location)

  • System.Data.SqlClient: Removed from MouseWithoutBorders projects and central Directory.Packages.props pin. It was a transitive dependency of Microsoft.Windows.Compatibility but PowerToys has zero SQL database usage.
  • Unused using import: Removed using System.ServiceModel.Channels from MouseWithoutBorders Program.cs (no WCF usage).
  • MFC/C++ AMP/OpenMP DLLs: Added RemoveUnusedVCRuntimeDlls target in Directory.Build.targets to clean up MFC, C++ AMP, and OpenMP DLLs that leak from the VC++ Redistributable tree but are not imported by any PowerToys binary (verified with dumpbin /dependents across all 2176 installed binaries). Also excluded MFC DLLs from installer file collection.

2. WinUI3Apps hard-link deduplication (~318 MB savings)

Build-time: generateAllFileComponents.ps1 now computes the SHA256 intersection of root and WinUI3Apps files, removes duplicates from the WinUI3Apps WXS component list, and writes a hardlinks.txt manifest.

Install-time: CreateWinAppSDKHardlinksCA custom action reads hardlinks.txt after InstallFiles and creates hard-links from root files into the WinUI3Apps directory. Falls back to file copy if hard-linking fails (e.g. cross-volume). DeleteWinAppSDKHardlinksCA removes them before RemoveFiles on uninstall.

Edge cases handled:

  • Empty duplicate list: hardlinks.txt always written, CA handles empty
  • All files duplicated: Generate-FileComponents returns early for empty list
  • Cross-volume install: CreateHardLinkW failure falls back to copy
  • Missing source: logged and skipped, install continues
  • Upgrade: CA runs on both fresh install and upgrade

Detailed Description of the Pull Request / Additional comments

These changes are purely build/installer infrastructure — no runtime behavior changes to any PowerToys module.

Validation Steps Performed

  • Verified no PowerToys binary imports MFC/AMP/OpenMP DLLs via dumpbin /dependents
  • Verified System.Data.SqlClient has no usages in PowerToys code
  • Build succeeds with exit code 0

yeelam-gordon and others added 2 commits April 3, 2026 13:10
- Remove System.Data.SqlClient PackageReference from MouseWithoutBorders,
  MouseWithoutBordersHelper, and MouseWithoutBordersService .csproj files.
  It was pinned as a transitive dependency of Microsoft.Windows.Compatibility
  but PowerToys has zero SQL database usage.

- Remove central PackageVersion pin for System.Data.SqlClient from
  Directory.Packages.props.

- Remove unused 'using System.ServiceModel.Channels' import from
  MouseWithoutBorders Program.cs (no WCF usage in the codebase).

- Exclude MFC DLLs (mfc140.dll, mfc140u.dll, mfcm140.dll, mfcm140u.dll)
  from installer file collection in generateAllFileComponents.ps1.

- Add RemoveUnusedVCRuntimeDlls target in Directory.Build.targets to
  clean up MFC, C++ AMP, and OpenMP DLLs from build output after
  CopyCppRuntimeToOutputDir copies them. These leak from the VC++
  Redistributable tree (Microsoft.VC14x.MFC, .CXXAMP) but no PowerToys
  binary imports them — verified with dumpbin /dependents across all
  2176 installed binaries. Saves ~11 MB per output location.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Build-time: generateAllFileComponents.ps1 now computes the SHA256
intersection of root and WinUI3Apps files, removes duplicates from
the WinUI3Apps WXS component list, and writes a hardlinks.txt manifest.
This reduces both installer size and installed size by ~318 MB.

Install-time: CreateWinAppSDKHardlinksCA reads hardlinks.txt after
InstallFiles and creates hard-links from root files into WinUI3Apps.
Falls back to file copy if hard-linking fails (e.g. cross-volume).
DeleteWinAppSDKHardlinksCA removes them before RemoveFiles on uninstall.

Edge cases handled:
- Empty duplicate list: hardlinks.txt always written, CA handles empty
- All files duplicated: Generate-FileComponents returns early for empty list
- Cross-volume install: CreateHardLinkW failure falls back to copy
- Missing source: logged and skipped, install continues
- Upgrade: CA runs on both fresh install and upgrade

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@crutkas
Copy link
Copy Markdown
Member

crutkas commented Apr 3, 2026

❤️❤️❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants