Skip to content

Migrate C++ projects from packages.config to PackageReference with Central Package Management #298

@Alan-Jowett

Description

@Alan-Jowett

Summary

Migrate C++ projects from the legacy packages.config approach to the modern PackageReference format with NuGet Central Package Management (CPM). This will eliminate the local packages/ directory (~2.5 GB) and centralize version management.

Current State

The repository has 12 packages.config files across C++ projects:

  • ebpf_extensions/ntosebpfext/sys/packages.config
  • ebpf_extensions/ntosebpfext/user/packages.config
  • ebpf_extensions/neteventebpfext/sys/packages.config
  • ebpf_extensions/neteventebpfext/user/packages.config
  • tests/ntosebpfext/ntosebpfext_unit/packages.config
  • tests/neteventebpfext/neteventebpfext_unit/packages.config
  • tests/neteventebpfext/netevent_sim/packages.config
  • tools/process_monitor_bpf/packages.config
  • tools/ntos_ebpf_ext_export_program_info/packages.config
  • tools/netevent_ebpf_ext_export_program_info/packages.config
  • tools/netevent_monitor/packages.config
  • scripts/setup_build/packages.config

These reference the following packages:

  • eBPF-for-Windows.x64 (1.0.0-rc1)
  • Microsoft.Windows.SDK.CPP (10.0.26100.4204)
  • Microsoft.Windows.SDK.CPP.arm64 (10.0.26100.4204)
  • Microsoft.Windows.SDK.CPP.x64 (10.0.26100.4204)
  • Microsoft.Windows.SDK.CPP.x86 (10.0.26100.4204)
  • Microsoft.Windows.WDK.ARM64 (10.0.26100.4204)
  • Microsoft.Windows.WDK.x64 (10.0.26100.4204)
  • Microsoft.Windows.WDK.x86 (10.0.26100.4204)

The Directory.Packages.props file exists but has ManagePackageVersionsCentrally set to false and only covers .NET packages.

Benefits

1. Eliminates ~2.5 GB local packages directory

With packages.config, NuGet restores packages to a local packages/ folder in the repo. With PackageReference, packages are stored in the global NuGet cache (%userprofile%\.nuget\packages), which is shared across all repositories.

2. Faster builds and clones

  • No need to download/extract packages per-repo
  • Smaller repo footprint (if packages/ was ever accidentally committed)
  • Shared cache means packages only download once per machine

3. Centralized version management

All package versions defined in one place (Directory.Packages.props), making it easier to:

  • Update package versions across all projects atomically
  • Ensure version consistency across the solution
  • Review package dependencies in one file

4. Better dependency resolution

PackageReference uses transitive dependency resolution, automatically handling package dependencies without manual management.

5. Simplified project files

PackageReference entries go directly in .vcxproj files, eliminating the need for separate packages.config files.

6. Aligns with .NET projects

The .NET projects in this repo (process_monitor, process_monitor.Library, process_monitor.Tests) already use PackageReference. This change would make all projects consistent.

Proposed Changes

  1. Update Directory.Packages.props:

    • Set ManagePackageVersionsCentrally to true
    • Add C++ package versions:
      xml <PackageVersion Include="eBPF-for-Windows.x64" Version="1.0.0-rc1" /> <PackageVersion Include="Microsoft.Windows.SDK.CPP" Version="10.0.26100.4204" /> <PackageVersion Include="Microsoft.Windows.SDK.CPP.arm64" Version="10.0.26100.4204" /> <PackageVersion Include="Microsoft.Windows.SDK.CPP.x64" Version="10.0.26100.4204" /> <PackageVersion Include="Microsoft.Windows.SDK.CPP.x86" Version="10.0.26100.4204" /> <PackageVersion Include="Microsoft.Windows.WDK.ARM64" Version="10.0.26100.4204" /> <PackageVersion Include="Microsoft.Windows.WDK.x64" Version="10.0.26100.4204" /> <PackageVersion Include="Microsoft.Windows.WDK.x86" Version="10.0.26100.4204" />
  2. Migrate each .vcxproj: Add <PackageReference Include="..." /> (without version) for each package

  3. Delete packages.config files: Remove all 12 files

  4. Update .gitignore: Ensure packages/ is ignored (if not already)

  5. Delete local packages/ directory: Remove the ~2.5 GB folder

  6. Update submodules: The external/usersim submodule also has packages.config files that would benefit from the same migration (separate effort)

References

Metadata

Metadata

Labels

enhancementNew feature or requesttriagedThe issue is triaged by the maintainers.

Type

No fields configured for Task.

Projects

Status
In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions