Skip to content

Commit ac646ff

Browse files
radicalCopilot
andcommitted
fix(cli): require installed source for local template hives
The template package resolver should not treat every registered `pr-*` channel as an installed hive. That made the hive-gate test select the PR channel even when no local hive/source existed on disk. Keep the dogfood install-prefix behavior, but only count a local-build channel as a hive signal when its Aspire package source is a local path that exists. Arbitrary registered channels without installed packages keep falling back to the implicit channel. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8f89514 commit ac646ff

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ public async Task<TemplatePackageSelection> ResolveTemplatePackageAsync(Template
209209
// Honor PR hives only when the caller opts in. Init suppresses this so a developer
210210
// with stale ~/.aspire/hives/* doesn't get a different template than on a clean machine.
211211
// PR dogfood installs can discover a matching local-build channel outside the default
212-
// hives directory, so also treat an explicit local-build channel as a hive signal.
212+
// hives directory, so also treat an installed local-build source as a hive signal.
213213
var hasPrHives = query.IncludePrHives &&
214214
(executionContext.GetHiveCount() > 0 ||
215-
allChannels.Any(c => c.Type is PackageChannelType.Explicit && VersionHelper.IsLocalBuildChannel(c.Name)));
215+
allChannels.Any(static c => c.Type is PackageChannelType.Explicit && HasInstalledLocalBuildPackageSource(c)));
216216

217217
IEnumerable<PackageChannel> channels;
218218
if (!string.IsNullOrEmpty(query.RequestedChannel))
@@ -296,6 +296,16 @@ await Parallel.ForEachAsync(channels, cancellationToken, async (channel, ct) =>
296296
return new TemplatePackageSelection(prompted.Package, prompted.Channel);
297297
}
298298

299+
private static bool HasInstalledLocalBuildPackageSource(PackageChannel channel)
300+
{
301+
return VersionHelper.IsLocalBuildChannel(channel.Name) &&
302+
channel.Mappings?.Any(static mapping =>
303+
mapping.PackageFilter.StartsWith("Aspire", StringComparison.OrdinalIgnoreCase) &&
304+
mapping.PackageFilter != PackageMapping.AllPackages &&
305+
!UrlHelper.IsHttpUrl(mapping.Source) &&
306+
Directory.Exists(mapping.Source)) == true;
307+
}
308+
299309
/// <summary>
300310
/// Installs the resolved Aspire project templates package, generating a temporary NuGet.config from the channel mappings when the channel is explicit.
301311
/// </summary>

0 commit comments

Comments
 (0)