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

NSWAG执行报错'Unrecognised arguments are present'问题求助

针对NSwag运行时参数错误与版本不兼容的解决方案
  • 修正CLI参数格式:先执行nswag --help查看run命令的参数规范,部分NSwag版本已将/runtime改为--runtime格式,替换后重试命令:

    call nswag run generate.Service.nswag --runtime:Net60
    
  • 同步配置文件与环境运行时:打开generate.Service.nswag配置文件,找到<Runtime>节点(比如原配置是<Runtime>NetCore21</Runtime>),将其修改为当前环境可用的运行时版本(如Net60或Net70),保存后直接执行:

    call nswag run generate.Service.nswag
    
  • 改用本地NSwag工具:全局安装的NSwag易与项目依赖冲突,先卸载全局版本:

    npm uninstall -g nswag
    

    再在项目根目录安装本地依赖:

    npm install nswag --save-dev
    

    最后通过本地路径执行命令:

    call node_modules/.bin/nswag run generate.Service.nswag --runtime:Net60
    
  • 用指定.NET版本运行NSwag:若环境存在多版本.NET,直接通过对应版本的dotnet工具安装并运行NSwag:

    # 安装适配Net60的NSwag版本(如v13.19.0)
    dotnet tool install -g NSwag.ConsoleCore --version 13.19.0
    dotnet nswag run generate.Service.nswag --runtime Net60
    

内容的提问来源于stack exchange,提问作者Yogurtu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 00:38:16