{"record":{"id":"a614a56dabc45edd","repo":"microsoft/aspire","slug":"unsupported-apphost-file-type-projectfile-extension-expected","errorCode":null,"errorMessage":"Unsupported AppHost file type: {projectFile.Extension}. Expected .csproj or .cs file.","messagePattern":"Unsupported AppHost file type: (.+?)\\. Expected \\.csproj or \\.cs file\\.","errorType":"exception","errorClass":"ProjectUpdaterException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Projects/ProjectUpdater.cs","lineNumber":687,"sourceCode":"            // Display migration feedback messages\n            if (migrationInfo.WillMigrateToNewFormat)\n            {\n                interactionService.DisplaySubtleMessage(string.Format(CultureInfo.InvariantCulture,\n                    UpdateCommandStrings.MigratedToNewSdkFormat, package.Version));\n            }\n\n            if (migrationInfo.WillRemoveAppHostPackage)\n            {\n                interactionService.DisplaySubtleMessage(UpdateCommandStrings.RemovedObsoleteAppHostPackage);\n            }\n        }\n        else if (string.Equals(projectFile.Extension, \".cs\", StringComparison.OrdinalIgnoreCase))\n        {\n            await UpdateSdkVersionInSingleFileAppHostAsync(projectFile, package);\n        }\n        else\n        {\n            throw new ProjectUpdaterException(string.Format(CultureInfo.InvariantCulture,\n                \"Unsupported AppHost file type: {0}. Expected .csproj or .cs file.\", projectFile.Extension));\n        }\n    }\n\n    internal static async Task UpdateSdkVersionInProjectAppHostAsync(FileInfo projectFile, NuGetPackageCli package)\n    {\n        var projectDocument = new XmlDocument();\n        projectDocument.PreserveWhitespace = true;\n\n        projectDocument.Load(projectFile.FullName);\n\n        var projectNode = projectDocument.SelectSingleNode(\"/Project\");\n        if (projectNode is null)\n        {\n            throw new ProjectUpdaterException(string.Format(CultureInfo.InvariantCulture, UpdateCommandStrings.CouldNotFindRootProjectElementFormat, projectFile.FullName));\n        }\n\n        // Check if the SDK is set via the Sdk attribute on the Project element (new format)","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Projects/ProjectUpdater.cs#L669-L705","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Convert the AppHost project to C# (.csproj) or a single-file .cs AppHost, then re-run `aspire update`.","Manually update the Aspire.AppHost.Sdk / Aspire.* package versions in the non-C# AppHost file by hand.","If the extension is wrong (e.g. file misnamed), rename the file to the correct .csproj extension and retry."],"exampleFix":"// before\nMyApp.AppHost.vbproj\n// after\nMyApp.AppHost.csproj  (project converted to C#)","handlingStrategy":"validation","validationCode":"var ext = appHostFile.Extension.ToLowerInvariant();\nif (ext is not \".csproj\" and not \".cs\")\n    throw new NotSupportedException($\"AppHost '{appHostFile.Name}' is not a supported AppHost type (.csproj or .cs expected).\");","typeGuard":"bool IsSupportedAppHostFile(FileInfo f) => f.Extension is \".csproj\" or \".cs\";","tryCatchPattern":"try { await updater.UpdateAsync(...); }\ncatch (ProjectUpdaterException ex) when (ex.Message.Contains(\"Unsupported AppHost file type\"))\n{\n    // convert the project to C# or update versions manually\n}","preventionTips":["Keep the AppHost as a C# project (.csproj) or single-file .cs AppHost.","Before running `aspire update`, list AppHost files and check extensions.","Convert VB/F# AppHosts to C# before Aspire version updates."],"tags":["aspire-cli","apphost","unsupported-file-type","update-command"],"backgroundTag":"unsupported-operation","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}