使用 dotnet run 时无法将 -p 参数传递给 .NET 应用程序

MrS*_*alk 0 c# msbuild .net-core

我正在尝试使用以下命令将命令行参数传递-p给我的 .NET Core 应用程序dotnet rundotnet run -p /Users/user/Pictures但是,当我这样做时,我收到如下错误消息。它看起来像是dotnet run试图打开一个项目文件夹,而不是将此参数传递给我的应用程序。我可以将其他内容(例如 )传递-q给我的应用程序。

-p使用时如何传递到我的应用程序dotnet run

错误是这样的:

$ dotnet run -p /Users/user/Pictures

MSBUILD : error MSB1001: Unknown switch.
Switch: /Users/user/Pictures
For switch syntax, type "MSBuild -help"
The build failed. Fix the build errors and run again.
Run Code Online (Sandbox Code Playgroud)

我正在尝试编写一个带有如下开关的 .NET 应用程序:

Usage: du [-s] [-p] [-b] "path"

Summarize disk usage of the set of FILES, recursively for directories.
You MUST specify one of the parameters, -s, -p, or -b
-s      Run in single threaded mode
-p      Run in parallel mode (uses all available processors)
-b      Run in both parallel and single threaded mode.Runs parallel followed by sequential mode
Run Code Online (Sandbox Code Playgroud)

chw*_*arr 7

您需要使用 来--告诉dotnet run您已完成传递参数,其余部分应传递给正在运行的应用程序。-p是 的短开关dotnet run --project,用于指定要构建和运行的项目文件(例如,.csproj 文件)。您的-p特定于您的应用程序。

dotnet run -- -p /Users/user/Pictures
Run Code Online (Sandbox Code Playgroud)