fix: Prevent local NuGet modules from running in CI PR builds#1680
Conversation
SummaryFixes CI PR builds by preventing local NuGet modules from being registered when running in CI environments. Critical IssuesNone found ✅ SuggestionsLogic clarity improvement: Minor: Namespace organization Verdict✅ APPROVE - No critical issues The fix correctly addresses the root cause by distinguishing between local development and CI environments using BuildSystemDetector. The dependency on PackagePathsParserModule will no longer be missing in CI PR builds since those modules will not be registered at all. |
6f44d6d to
502e1cb
Compare
SummaryFixes module registration logic to distinguish between local development and CI PR builds by using BuildSystemDetector. Critical IssuesNone found ✅ SuggestionsLogic clarity in edge case: The current implementation has three paths:
The third case (PR builds) intentionally falls through both conditionals, which is correct but not immediately obvious. The comment "else: CI Development mode (PR builds) - don't register..." helps, but consider explicitly checking for this case to make the intent clearer: if (isLocalDevelopment)
{
// Local NuGet modules
}
else if (!context.HostingEnvironment.IsDevelopment())
{
// Production modules
}
else
{
// PR builds in CI - explicitly do nothing
// BuildSystemDetector.Instance.IsKnownBuildAgent is true here
}This makes it impossible to accidentally break the PR build case when refactoring. Minor: The variable name Verdict✅ APPROVE - No critical issues The logic is sound and correctly handles the three deployment scenarios. The use of |
The build pipeline was incorrectly registering local NuGet modules when running in CI on PR branches. This happened because: 1. The GitHub Actions workflow sets DOTNET_ENVIRONMENT=Development for non-main branches (PRs) 2. IsDevelopment() returns true in this case 3. Local NuGet modules (which depend on PackagePathsParserModule) were registered even though they're meant only for local development The fix uses BuildSystemDetector.Instance.IsKnownBuildAgent to distinguish between true local development (no CI system detected) and CI runs with Development environment. Now: - Local development: Registers local NuGet modules (dev machine, no CI) - CI Production (main): Registers NuGet upload and release modules - CI Development (PRs): Registers neither (just runs tests/build) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
502e1cb to
01be799
Compare
SummaryFixes pipeline failures on PR branches by preventing local NuGet modules from being registered when running in CI. Critical Issues1. Implementation doesn't match PR description 🚨 The PR description states:
But the actual implementation manually checks environment variables: var isRunningInCI = \!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI"))
|| \!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"))
|| \!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TF_BUILD"))
|| \!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITLAB_CI"));This duplicates logic from Recommendation: Use the existing var isLocalDevelopment = context.HostingEnvironment.IsDevelopment()
&& \!BuildSystemDetector.Instance.IsKnownBuildAgent;This eliminates duplicate logic and ensures consistency across the codebase. 2. Checking undefined The code checks for a
If SuggestionsComment clarity: The comment on line 71 says "Production environment (main branch CI)" but this condition ( Verdict
|
Summary
Fixes the pipeline failure where CI incorrectly registers local NuGet modules on PR branches.
Root Cause
The GitHub Actions workflow sets
DOTNET_ENVIRONMENT=Developmentfor non-main branches. This causedIsDevelopment()to returntrue, registering local NuGet modules (UploadPackagesToLocalNuGetModule) that depend onPackagePathsParserModulewhich wasn't registered in that code path.Fix
Modified
Program.csto useBuildSystemDetector.Instance.IsKnownBuildAgentto distinguish:The
BuildSystemDetectoralready exists and detects CI via environment variables likeGITHUB_ACTIONS,TF_BUILD,GITLAB_CI, etc.Test plan
ModuleNotRegisteredException🤖 Generated with Claude Code