{"record":{"id":"88ffa4413f479e8b","repo":"RicoSuter/NSwag","slug":"unsupported-target-framework-projectmetadata","errorCode":null,"errorMessage":"Unsupported target framework '{projectMetadata.TargetFrameworkIdentifier}'.","messagePattern":"Unsupported target framework '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs","lineNumber":173,"sourceCode":"                var executorBinary = Path.Combine(toolDirectory, binaryName);\n\n                if (!File.Exists(executorBinary))\n                {\n                    binaryName = LauncherBinaryName + \".exe\";\n                    executorBinary = Path.Combine(toolDirectory, binaryName);\n                }\n\n                if (!File.Exists(executorBinary))\n                {\n                    throw new InvalidOperationException($\"Unable to locate {binaryName} in {toolDirectory}.\");\n                }\n\n                args.Add(executorBinary);\n            }\n#endif\n            else\n            {\n                throw new InvalidOperationException($\"Unsupported target framework '{projectMetadata.TargetFrameworkIdentifier}'.\");\n            }\n\n            var commandFile = Path.GetTempFileName();\n            var outputFile = Path.GetTempFileName();\n            File.WriteAllText(commandFile, JsonConvert.SerializeObject(this));\n            cleanupFiles.Add(commandFile);\n            cleanupFiles.Add(outputFile);\n\n            args.Add(commandFile);\n            args.Add(outputFile);\n            args.Add(projectMetadata.AssemblyName);\n            args.Add(toolDirectory);\n\n            try\n            {\n                var exitCode = await Exe.RunAsync(executable, args, verboseHost).ConfigureAwait(false);\n                if (exitCode != 0)\n                {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/RicoSuter/NSwag/blob/63daf8fcc3a25151b62eb4b326a1e8ea048a0d41/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs#L155-L191","documentation":"After resolving MSBuild metadata, RunAsync dispatches to a launcher appropriate to the project's TargetFrameworkIdentifier. It supports .NET Framework (NET462 build) and .NET Core (identifiers equal to '.NETCoreApp' or starting with 'net'); anything else — e.g. a netstandard class library or an unrecognized identifier — results in this 'Unsupported target framework' error.","triggerScenarios":"Pointing aspnetcore2openapi at a project whose evaluated TargetFrameworkIdentifier is neither '.NETFramework'/'net'-prefixed Core App (e.g. '.NETStandard', or metadata evaluation returned empty/garbled because the project is not an executable ASP.NET Core app).","commonSituations":"Accidentally targeting a netstandard class library that hosts controllers but is not a runnable app; malformed or missing TargetFramework in the csproj; custom SDKs that report unusual framework identifiers; running the .NET Framework NSwag build against a .NET 5+ project (or vice versa) with mismatched identifier parsing.","solutions":["Run the command against an executable ASP.NET Core project (Microsoft.NET.Sdk.Web) with a supported <TargetFramework> (netcoreapp/netN or net4x).","Install the NSwag flavor matching your project: NSwag.ConsoleCore for .NET Core/5+ projects, NSwag.Console for .NET Framework projects.","Explicitly pass --targetframework matching the project's TFM if multi-targeting is confusing metadata evaluation.","Fix a missing or invalid <TargetFramework> element in the .csproj."],"exampleFix":"// before (csproj)\n<TargetFramework>netstandard2.0</TargetFramework>\n// after\n<TargetFramework>net8.0</TargetFramework>","handlingStrategy":"validation","validationCode":"var tfm = projectMetadata.TargetFrameworkIdentifier;\nvar supported = tfm == \".NETFramework\" || tfm == \".NETCoreApp\" || tfm.StartsWith(\"net\");\nif (!supported)\n    throw new InvalidOperationException($\"Project must target net4x or netcoreapp/netN, got: {tfm}\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await command.RunAsync(processor, host);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Unsupported target framework\"))\n{\n    // choose the NSwag flavor matching the project TFM or fix the csproj TFM\n}","preventionTips":["Only run aspnetcore2openapi against executable ASP.NET Core (Microsoft.NET.Sdk.Web) or .NET Framework web projects.","Don't point NSwag at netstandard class libraries.","Match the NSwag distribution (Console vs ConsoleCore) to the project's TFM."],"tags":["target-framework","dotnet","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"63daf8fcc3a25151b62eb4b326a1e8ea048a0d41","analyzedAt":"2026-09-14T11:38:15.205Z","contentChangedAt":"2026-09-14T11:38:15.205Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}