microsoft/aspire · error · InvalidOperationException
(dynamic staging-channel unavailable message from…
Error message
{reason} (dynamic staging-channel unavailable message from IPackagingService.GetStagingChannelUnavailableReason) What it means
Before performing a bundled restore from a staging channel, PrebuiltAppHostServer consults IPackagingService.GetStagingChannelUnavailableReason(). If that returns a non-null reason string, the staging channel cannot be used (e.g. not configured, disabled, or unsupported) and the CLI throws InvalidOperationException with that reason as the message. The '{reason} (dynamic staging-channel unavailable message...)' text is the template — the actual thrown message is the reason returned by the service.
Solutions
- Switch to a stable/GA channel (unset ASPIRE_STAGING_CHANNEL or set ASPIRE_CHANNEL=stable) and retry.
- Read the thrown reason message — it comes from GetStagingChannelUnavailableReason and states the exact channel problem — and fix that condition.
- Verify network access to the staging NuGet feed; configure proxy/credentials if the feed is blocked.
- Use a CLI version whose channel is actually published.
Example fix
// before export ASPIRE_STAGING_CHANNEL=daily // after unset ASPIRE_STAGING_CHANNEL # or: export ASPIRE_CHANNEL=stable
Defensive patterns
Strategy: fallback
Validate before calling
var reason = packagingService.GetStagingChannelUnavailableReason();
if (reason is not null) { Console.WriteLine($"Staging channel unavailable: {reason}"); /* switch to stable */ } Type guard
static bool StagingChannelUsable(IPackagingService svc) => svc.GetStagingChannelUnavailableReason() is null;
Try / catch
try { await server.RunAsync(ct); }
catch (InvalidOperationException ex) when (ex.Message.Contains("channel"))
{ logger.LogWarning("Staging channel unavailable: {Reason} — retrying with stable channel", ex.Message); await RetryWithStableChannelAsync(ct); } Prevention
- Pin ASPIRE_CHANNEL/staging-channel config to a channel you know is published.
- Unset staging-channel overrides for production/CI runs.
- Check feed connectivity and proxy settings before bundled restores.
- Keep the CLI on a released version whose channel exists.
When it happens
Trigger: Initiating a bundled restore of a prebuilt AppHost while the staging feed is unavailable: ASPIRE_STAGING_CHANNEL / channel configuration points at a channel that is disabled, not yet published, or not enabled for the current build quality.
Common situations: Using a daily/staging CLI build against a channel whose feed hasn't been published; setting ASPIRE_CHANNEL or ASPIRE_STAGING_CHANNEL to an invalid or retired channel; corporate proxies blocking the staging feed so the service reports it unavailable.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- aspire-managed not found in layout.
- Bundle layout not found. Cannot perform NuGet restore in…
- Bundle layout not found. Cannot perform NuGet search in…
- CLI path must be provided
- Failed to discover NuGet.config files.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/58709e82c0e88489.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs:1001
/// <summary>
/// Throws when the caller asked for the staging channel but the running CLI's packaging
/// service refuses to synthesize one (daily/local/pr-<c>N</c> identity without
/// <c>overrideStagingFeed</c> or the <c>StagingChannelEnabled</c> feature flag). Surfaces
/// the same actionable reason the <c>update</c> and <c>new</c> commands display so the
/// bundled AppHost restore path doesn't silently downgrade to the daily feed.
/// </summary>
private void ThrowIfStagingUnavailable(string? requestedChannel)
{
if (!string.Equals(requestedChannel, PackageChannelNames.Staging, StringComparisons.ChannelName))
{
return;
}
var reason = _packagingService.GetStagingChannelUnavailableReason();
if (reason is not null)
{
throw new InvalidOperationException(reason);
}
}
/// <summary>
/// Gets NuGet sources from the resolved channel for bundled restore.
/// </summary>
internal async Task<IEnumerable<string>?> GetNuGetSourcesAsync(string? requestedChannel, string? packageSourceOverride, CancellationToken cancellationToken)
{
// Refuse to silently downgrade staging restores to the shared daily feed when the running
// CLI cannot synthesize a real staging channel (daily/local/pr-<N>). PackagingService omits
// the staging channel in that case; without this check the lookup below falls through to
// "all explicit channels" — which on a daily CLI is the shared daily feed — and restore
// silently succeeds against the wrong feed. Surfacing the actionable
// GetStagingChannelUnavailableReason() mirrors UpdateCommand/NewCommand and closes the
// bundled-AppHost arm of https://github.com/microsoft/aspire/issues/16652.
ThrowIfStagingUnavailable(requestedChannel);
var sources = new List<string>();View on GitHub (pinned to 25830f84bd)