[build] Fix Bazel NuGet push implementation#16950
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR fixes the .NET NuGet package publishing implementation in Bazel by correcting runfiles handling and improving the reliability of push operations. The fix addresses issues with executable resolution and adds safety flags to prevent duplicate uploads.
Changes:
- Fixed runfiles handling by explicitly including the dotnet executable in runfiles dependencies
- Implemented dynamic runfiles directory location for Unix platforms with proper fallback logic
- Added
--skip-duplicateand--no-symbolsflags to both Unix and Windows push commands for safer operations
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
dotnet/private/nuget_push.bzl:77
- The Windows script uses a different path resolution approach compared to Unix. While Unix now uses RUNFILES_DIR for both dotnet and nupkg files, Windows continues to use relative paths from the script location. This inconsistency could lead to different behavior and potential failures in scenarios where one approach works but the other doesn't, particularly with external repositories or symbolic links. Consider updating the Windows implementation to use a similar runfiles-based approach for consistency and robustness.
'"%%DOTNET%%" nuget push "%s" --api-key "%%NUGET_API_KEY%%" --source "%%NUGET_SOURCE%%" --skip-duplicate --no-symbols' % nupkg_path,
)
push_commands.append("if %%ERRORLEVEL%% neq 0 exit /b %%ERRORLEVEL%%")
dotnet_path = dotnet.short_path.replace("/", "\\")
script_content = """@echo off
set DOTNET=%~dp0{dotnet_path}
User description
💥 What does this PR do?
🔧 Implementation Notes
This fix was verified successful during yesterday's release
🔄 Types of changes
PR Type
Bug fix
Description
Fix NuGet package publishing via Bazel by correcting runfiles handling
Add
dotnetexecutable to runfiles dependencies for proper resolutionUpdate Unix script to locate runfiles directory dynamically
Add
--skip-duplicateand--no-symbolsflags to push commandsDiagram Walkthrough
File Walkthrough
nuget_push.bzl
Fix NuGet push runfiles and add CLI flagsdotnet/private/nuget_push.bzl
dotnetexecutable torunfiles list
instead of relying on relative paths
--skip-duplicateand--no-symbolsflags to both Unix and WindowsNuGet push commands
stripping leading
../from dotnet path