microsoft/aspire · error · ProjectUpdaterException

Unsupported AppHost file type

Error message

Unsupported AppHost file type: {projectFile.Extension}. Expected .csproj or .cs file.

What it means

The Aspire CLI AppHost updater only knows how to update SDK versions in two AppHost shapes: a .csproj project file and a single-file .cs AppHost. When the AppHost file's extension is neither (e.g. .vbproj, .fsproj), UpdateSdkVersionInAppHostAsync throws ProjectUpdaterException because it has no code path to edit that format.

Solutions

  1. Convert the AppHost project to C# (.csproj) or a single-file .cs AppHost, then re-run `aspire update`.
  2. Manually update the Aspire.AppHost.Sdk / Aspire.* package versions in the non-C# AppHost file by hand.
  3. If the extension is wrong (e.g. file misnamed), rename the file to the correct .csproj extension and retry.

Example fix

// before
MyApp.AppHost.vbproj
// after
MyApp.AppHost.csproj  (project converted to C#)
Defensive patterns

Strategy: validation

Validate before calling

var ext = appHostFile.Extension.ToLowerInvariant();
if (ext is not ".csproj" and not ".cs")
    throw new NotSupportedException($"AppHost '{appHostFile.Name}' is not a supported AppHost type (.csproj or .cs expected).");

Type guard

bool IsSupportedAppHostFile(FileInfo f) => f.Extension is ".csproj" or ".cs";

Try / catch

try { await updater.UpdateAsync(...); }
catch (ProjectUpdaterException ex) when (ex.Message.Contains("Unsupported AppHost file type"))
{
    // convert the project to C# or update versions manually
}

Prevention

When it happens

Trigger: Running `aspire update` (UpdateSdkVersionInAppHostAsync) against an AppHost whose file extension is not .csproj or .cs — e.g. a Visual Basic (.vbproj) or F# (.fsproj) AppHost project, or a renamed file.

Common situations: Migrating an older app whose AppHost was authored in VB.NET/F# and then running the update command; a project file with an unusual extension passed as the AppHost; a typo-ed or renamed AppHost file discovered late in an update flow.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/a614a56dabc45edd. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/Projects/ProjectUpdater.cs:687

            // Display migration feedback messages
            if (migrationInfo.WillMigrateToNewFormat)
            {
                interactionService.DisplaySubtleMessage(string.Format(CultureInfo.InvariantCulture,
                    UpdateCommandStrings.MigratedToNewSdkFormat, package.Version));
            }

            if (migrationInfo.WillRemoveAppHostPackage)
            {
                interactionService.DisplaySubtleMessage(UpdateCommandStrings.RemovedObsoleteAppHostPackage);
            }
        }
        else if (string.Equals(projectFile.Extension, ".cs", StringComparison.OrdinalIgnoreCase))
        {
            await UpdateSdkVersionInSingleFileAppHostAsync(projectFile, package);
        }
        else
        {
            throw new ProjectUpdaterException(string.Format(CultureInfo.InvariantCulture,
                "Unsupported AppHost file type: {0}. Expected .csproj or .cs file.", projectFile.Extension));
        }
    }

    internal static async Task UpdateSdkVersionInProjectAppHostAsync(FileInfo projectFile, NuGetPackageCli package)
    {
        var projectDocument = new XmlDocument();
        projectDocument.PreserveWhitespace = true;

        projectDocument.Load(projectFile.FullName);

        var projectNode = projectDocument.SelectSingleNode("/Project");
        if (projectNode is null)
        {
            throw new ProjectUpdaterException(string.Format(CultureInfo.InvariantCulture, UpdateCommandStrings.CouldNotFindRootProjectElementFormat, projectFile.FullName));
        }

        // Check if the SDK is set via the Sdk attribute on the Project element (new format)

View on GitHub (pinned to 25830f84bd)