You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NSwag项目构建报错:‘run’命令未识别,退出码9009

Fix for NSwag Build Error: 'run' is not recognized (Exit Code 9009)

Let's break down what's going wrong here: Your BeforeBuild step is trying to execute run C:\agent_work\8\s\Web\webapi.nswag, but your build agent's shell (likely Windows CMD or PowerShell) doesn't recognize run as a valid standalone command. Exit code 9009 almost always means the system can't locate the executable you're trying to invoke.

Here's how to fix this issue step by step:

1. Use the correct NSwag command syntax

NSwag doesn't use a standalone run command—you need to call the NSwag executable first, then pass run as an argument. The exact command depends on how you installed NSwag:

Option A: Globally installed NSwag CLI

If you installed NSwag globally (via NuGet, Chocolatey, or the official installer), update your BeforeBuild command to:

nswag run "C:\agent_work\8\s\Web\webapi.nswag"

Option B: Local .NET Tool installation

If you added NSwag as a local .NET tool in your project (via dotnet tool install NSwag.ConsoleCore), use this command instead:

dotnet nswag run "C:\agent_work\8\s\Web\webapi.nswag"

2. Validate your build agent environment

  • For global installations: Confirm the NSwag executable path is added to the system PATH variable on your build agent. Test this manually by running nswag --version in the agent's command prompt—if it returns a version number, the path is configured correctly.
  • For local .NET tools: Add a pre-build step to run dotnet tool restore to ensure the NSwag tool is downloaded and available before executing the generation command.

3. Double-check the NSwag file path

Make sure the path to webapi.nswag is accurate (wrap it in quotes if there are spaces in the path, though your example doesn't have any). You can test the command directly in the agent's working directory to confirm it runs without errors before updating your build configuration.


内容的提问来源于stack exchange,提问作者Marcus Vinícius

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:05:26