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

如何在Release配置下使用dotnet watch并传递应用参数?

正确的命令语法

你需要在dotnet watch后加上run子命令,将编译配置参数-c release作为run的参数放在--之前,这样--后面的内容才会被正确传递给你的程序。

正确命令:

dotnet watch run -c release -- hello world

原因说明

你之前的命令dotnet watch -c release -- hello world缺少run子命令,导致-c和release被错误识别为dotnet watch的参数,最终被传递给了你的程序。加上run后,-c release会被识别为dotnet run的编译配置参数(指定Release模式编译),不会进入程序的args数组,只有--之后的hello world才会作为程序的命令行参数传入。

执行正确命令后,程序的输出会符合预期:

hello
world

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 07:00:54