Skip to content

Commit 6f44d6d

Browse files
thomhurstclaude
andcommitted
fix: Prevent local NuGet modules from running in CI PR builds
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>
1 parent ef8e766 commit 6f44d6d

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/ModularPipelines.Build/Program.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Extensions.Hosting;
44
using Microsoft.Extensions.Logging;
55
using Microsoft.Extensions.Options;
6+
using ModularPipelines;
67
using ModularPipelines.Build;
78
using ModularPipelines.Build.Modules;
89
using ModularPipelines.Build.Modules.LocalMachine;
@@ -60,17 +61,25 @@ await PipelineHostBuilder.Create()
6061
new InMemoryCredentialStore(new Credentials(githubToken)));
6162
});
6263

63-
if (context.HostingEnvironment.IsDevelopment())
64+
// Local NuGet modules should only run in local development, not CI
65+
// IsDevelopment() returns true for both local dev AND PR builds in CI (DOTNET_ENVIRONMENT=Development)
66+
// Use BuildSystemDetector to distinguish: local dev has no known build system
67+
var isLocalDevelopment = context.HostingEnvironment.IsDevelopment()
68+
&& !BuildSystemDetector.Instance.IsKnownBuildAgent;
69+
70+
if (isLocalDevelopment)
6471
{
6572
collection.AddModule<CreateLocalNugetFolderModule>()
6673
.AddModule<AddLocalNugetSourceModule>()
6774
.AddModule<UploadPackagesToLocalNuGetModule>();
6875
}
69-
else
76+
else if (!context.HostingEnvironment.IsDevelopment())
7077
{
78+
// Production environment (main branch CI)
7179
collection.AddModule<UploadPackagesToNugetModule>()
7280
.AddModule<CreateReleaseModule>();
7381
}
82+
// else: CI Development mode (PR builds) - don't register local NuGet or production upload modules
7483
})
7584
.ConfigurePipelineOptions((context, options) => options.DefaultRetryCount = 3)
7685
.SetLogLevel(LogLevel.Debug) // Temporarily hardcoded for debugging

0 commit comments

Comments
 (0)