我正在尝试在 Visual Studio 2019 和 WLS2 中调试 .net Core 控制台应用程序。 控制台应用程序在启动时需要一个命令行参数。
这是我的 launchSettings.json
{
"profiles": {
"ConsoleApp": {
"commandName": "Project",
"commandLineArgs": "--s",
},
"WSL 2": {
"commandName": "WSL2",
"commandLineArgs": "--s",
"distributionName": ""
}
}
}
使用“ConsoleApp”配置文件启动调试 session ,应用程序控制台按预期获得参数“--s”,但在使用“WSL 2”配置文件的 WSL 中执行调试时,我收到以下消息:
Unknown option: --s
.NET Core SDK (3.1.404)
Usage: dotnet [runtime-options] [path-to-application] [arguments]
最佳答案
WSL2 的 commandLineArgs
在未提供时默认为 dll 的名称。当您显式提供一个时,您还必须提供 dll 名称和参数。如果您的项目名称是 MyNamespace.MyProject,请按如下方式更新您的启动设置:
"WSL 2": {
"commandName": "WSL2",
"commandLineArgs": "MyNamespace.MyProject.dll --s",
"distributionName": ""
}
关于c# - Visual Studio WLS2 调试和命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69012111/