RicoSuter/NSwag · error · InvalidOperationException
Unable to locate in .
Error message
Unable to locate {binaryName} in {toolDirectory}. What it means
After choosing the correct launcher binary (NSwag.AspNetCore.Launcher.exe or .x86.exe based on bitness), the .NET Framework path of RunAsync verifies the binary exists in the NSwag tool directory and copies it next to the project's output. If the launcher exe is missing from the installation, this error is thrown, meaning the NSwag installation is incomplete or corrupted.
Solutions
- Reinstall/repair NSwag (reinstall the NSwag.Console NuGet package, Chocolatey package, or download the full release zip) so all binaries ship together.
- Verify NSwag.AspNetCore.Launcher.exe (and the .x86 variant) exist in the tool directory next to NSwag.Console.exe.
- Check antivirus/EDR quarantine logs and whitelist the NSwag tool directory.
- Copy the complete contents of a known-good NSwag installation directory rather than individual files.
Defensive patterns
Strategy: validation
Validate before calling
var launcher = Path.Combine(toolDir, "NSwag.AspNetCore.Launcher.exe");
if (!File.Exists(launcher))
throw new InvalidOperationException($"NSwag installation incomplete: {launcher} missing. Reinstall NSwag."); Try / catch
try
{
await command.RunAsync(processor, host);
}
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Unable to locate NSwag.AspNetCore.Launcher"))
{
// repair the NSwag installation before retrying
} Prevention
- Deploy NSwag as a whole package/zip, never by copying individual exes.
- Whitelist the NSwag tool directory in antivirus/EDR policies.
- Verify installation contents after package upgrades in CI.
When it happens
Trigger: Running the NET462 NSwag tool where File.Exists(Path.Combine(toolDirectory, 'NSwag.AspNetCore.Launcher[.x86].exe')) is false — i.e. the launcher executable was not deployed alongside NSwag.Console.exe.
Common situations: Partial NuGet package copies; manually copying just NSwag.Console.exe without its launcher siblings; antivirus quarantining or deleting the launcher exe; thin publish/deployment of the tool directory that skipped payload binaries.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- The ouput of is a 32-bit application and requires…
- The ouput of is a 64-bit application and requires…
AI-assisted analysis of RicoSuter/NSwag@63daf8fcc3 (2026-09-14).
Data as JSON: /api/errors/9903471630440ddf.
Report an issue: GitHub.
Appendix: source
Thrown at src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs:121
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))
{
var copiedAppConfig = Path.ChangeExtension(executable, ".exe.config");
File.Copy(appConfig, copiedAppConfig, overwrite: true);
cleanupFiles.Add(copiedAppConfig);
}
}
#else
var toolDirectory = AppContext.BaseDirectory;
if (!Directory.Exists(toolDirectory))
{View on GitHub (pinned to 63daf8fcc3)