-
Notifications
You must be signed in to change notification settings - Fork 254
Switch bpf2c to pull its own nuget dependencies #4502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors the bpf2c build to use NuGet package management, adds conditional restore for kernel-mode builds, and removes an unused script parameter.
- Replace manual SDK/WDK imports with PackageReference in kernel-mode project
- Remove manual imports in user-mode project (needs matching PackageReference updates)
- Add conditional
msbuild /t:restore
step and drop$Packages
param in the PowerShell script
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
tools/bpf2c/templates/user_mode_bpf2c.vcxproj | Removed manual SDK/WDK imports (needs new NuGet references) |
tools/bpf2c/templates/kernel_mode_bpf2c.vcxproj | Added ResolveNuGetPackages property and PackageReference items |
tools/bpf2c/Convert-BpfToNative.ps1.template | Removed $Packages param and inserted conditional restore |
Comments suppressed due to low confidence (4)
tools/bpf2c/Convert-BpfToNative.ps1.template:128
- [nitpick] The new conditional
$KernelMode
restore path isn't covered by existing tests. Consider adding a unit or integration test to verify thatmsbuild /t:restore
is only invoked when$KernelMode
is true.
if ($KernelMode) {
tools/bpf2c/templates/user_mode_bpf2c.vcxproj:51
- The user-mode project no longer has any PackageReference entries after removing manual imports. You should add an
<ItemGroup>
with matchingPackageReference
elements (e.g., for Microsoft.Windows.SDK.CPP and Microsoft.Windows.WDK) to restore dependencies via NuGet.
<PropertyGroup Label="Globals">
tools/bpf2c/Convert-BpfToNative.ps1.template:132
- The trailing backslashes inside
"$BinDir\"
and"$OutDir\"
will escape the closing quote in PowerShell. Consider doubling the backslashes ("$BinDir\\"
) or using single quotes to avoid unintended escape behavior.
msbuild /p:BinDir="$BinDir\" /p:OutDir="$OutDir\" /p:IncludeDir="$IncludeDir" /p:Configuration="$Configuration" /p:Platform="$Platform" /p:FileName="$FileName" /p:AdditionalOptions="$AdditionalOptions" /p:ResourceFile="$ResourceFile" $ProjectFile
tools/bpf2c/Convert-BpfToNative.ps1.template:132
- The variable
$IncludeDir
is passed to MSBuild but is not defined or set in the script parameters. Ensure$IncludeDir
is declared or removed if unnecessary.
msbuild /p:BinDir="$BinDir\" /p:OutDir="$OutDir\" /p:IncludeDir="$IncludeDir" /p:Configuration="$Configuration" /p:Platform="$Platform" /p:FileName="$FileName" /p:AdditionalOptions="$AdditionalOptions" /p:ResourceFile="$ResourceFile" $ProjectFile
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Description
Resolves: #4379
This pull request refactors the build process for the
bpf2c
tool by transitioning from manual package imports to NuGet-based package management, simplifying dependency handling. It also introduces conditional build steps for kernel-mode configurations and removes unused parameters from the script.Build process improvements:
tools/bpf2c/templates/kernel_mode_bpf2c.vcxproj
: Replaced manual package imports withPackageReference
elements for NuGet-based dependency management, including conditional references for host and target platforms. Added a property to disable NuGet package resolution during build.tools/bpf2c/templates/user_mode_bpf2c.vcxproj
: Removed manual package imports, aligning the user-mode project template with the kernel-mode template's streamlined dependency management approach.Script enhancements:
tools/bpf2c/Convert-BpfToNative.ps1.template
: Added conditional logic to restore NuGet packages during kernel-mode builds and removed the unused$Packages
parameter from the script. [1] [2]Testing
CI/CD
Documentation
No.
Installation
No.