RicoSuter/NSwag · error · InvalidOperationException

The ouput of is a 64-bit application and requires…

Error message

The ouput of {projectFile} is a 64-bit application and requires NSwag.Console to be processed.

What it means

Mirror image of the x86 check: if the project's PlatformTarget is not x86 (e.g. AnyCPU or x64), the .NET Framework flavor of NSwag must run as a 64-bit process. When a 32-bit NSwag process encounters such a project, it throws this error and directs the user to the 64-bit NSwag.Console tool.

Solutions

  1. Run the 64-bit NSwag.Console.exe instead of NSwag.Console.x86.exe.
  2. Ensure the CI/agent process is 64-bit so the correct tool variant is selected.
  3. If the project truly must be 32-bit, set PlatformTarget to x86 so it matches the x86 tool.

Example fix

// before
"C:\tools\nswag\NSwag.Console.x86.exe" aspnetcore2openapi /project:MyApi.csproj
// after
"C:\tools\nswag\NSwag.Console.exe" aspnetcore2openapi /project:MyApi.csproj
Defensive patterns

Strategy: validation

Validate before calling

var isX86 = string.Equals(platformTarget, "x86", StringComparison.OrdinalIgnoreCase);
if (!isX86 && !Environment.Is64BitProcess)
    Console.WriteLine("Project is 64-bit/AnyCPU: use 64-bit NSwag.Console.exe instead.");

Try / catch

try
{
    await command.RunAsync(processor, host);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("requires NSwag.Console to be processed"))
{
    // re-exec via the 64-bit tool binary
}

Prevention

When it happens

Trigger: Running NSwag.Console.x86.exe (Environment.Is64BitProcess == false) under the NET462 build against a project whose PlatformTarget is not 'x86', so RunAsync requires the 64-bit launcher.

Common situations: Someone installed the x86 NSwag build to solve a different project's bitness problem and reuses it for AnyCPU projects; 32-bit CI build agents; hardcoded paths to NSwag.Console.x86 in build scripts.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of RicoSuter/NSwag@63daf8fcc3 (2026-09-14). Data as JSON: /api/errors/f09ed57757588a70. Report an issue: GitHub.

Appendix: source

Thrown at src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs:112

            if (projectMetadata.TargetFrameworkIdentifier == ".NETFramework")
            {
                string binaryName;
                var is32BitProject = string.Equals(projectMetadata.PlatformTarget, "x86", StringComparison.OrdinalIgnoreCase);
                if (is32BitProject)
                {
                    if (Environment.Is64BitProcess)
                    {
                        throw new InvalidOperationException($"The ouput of {projectFile} is a 32-bit application and requires NSwag.Console.x86 to be processed.");
                    }

                    binaryName = LauncherBinaryName + ".x86.exe";
                }
                else
                {
                    if (!Environment.Is64BitProcess)
                    {
                        throw new InvalidOperationException($"The ouput of {projectFile} is a 64-bit application and requires NSwag.Console to be processed.");
                    }

                    binaryName = LauncherBinaryName + ".exe";
                }

                var executableSource = Path.Combine(toolDirectory, binaryName);
                if (!File.Exists(executableSource))
                {
                    throw new InvalidOperationException($"Unable to locate {binaryName} in {toolDirectory}.");
                }

                executable = Path.Combine(projectMetadata.OutputPath, binaryName);
                File.Copy(executableSource, executable, overwrite: true);
                cleanupFiles.Add(executable);

                var appConfig = Path.Combine(projectMetadata.OutputPath, projectMetadata.TargetFileName + ".config");
                if (File.Exists(appConfig))
                {

View on GitHub (pinned to 63daf8fcc3)