在Visual Studio Code中使用命令行提示符运行C#程序 [英] Running a C# program with command line prompts in Visual Studio Code

查看:42
本文介绍了在Visual Studio Code中使用命令行提示符运行C#程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio Code中运行一个用C#编写的继承项目.为了使该应用程序运行,它需要接受命令行输入(-t,-h等).我如何在Visual Studio中对此进行测试?

I am running an inherited project written in C# inside Visual Studio Code. In order for this application to run, it needs to take command line input (-t, -h, etc). How do I test this from inside Visual Studio?

目前(我一直在学习dotnet,C#,VS等),我有一个可以在vsc终端上运行的hello world程序.由于某种原因,我无法查明,可能是我的安装方式,无法识别 dotnet run -我必须向它提供指向dotnet.exe的显式路径: C:\ Program Files \ dotnet \ dotnet.exe运行

Currently (I've been learning dotnet, C#, VS, etc as I go) I have a hello world program I can run from vsc's terminal. For a reason I haven't been able to pinpoint, probably how I installed it, dotnet run isn't recognized - I have to feed it an explicit path to dotnet.exe: C:\Program Files\dotnet\dotnet.exe run

当程序需要命令行输入时,该怎么办?我在 C:\ Program Files \ dotnet \ dotnet.exe的暗处运行-t 可能无法正常工作,但我不确定还有什么尝试.

How can I do this when the program requires command line input? My shot in the dark of C:\Program Files\dotnet\dotnet.exe run -t predictably didn't work, but I'm not sure what else to try.

谢谢!

推荐答案

如果您使用 dotnet.exe run 来启动应用程序,则需要添加-开关语句,指示 dotnet.exe 将参数传递给您的应用程序.例如

If you are using dotnet.exe run to start your application you need add the -- switch statement to instruct dotnet.exe to pass the arguments to your application. For example

Microsoft文档

dotnet.exe运行--arg1 -arg2(等) dotnet 参数之后和程序特定之前注意-争论.

dotnet.exe run -- -arg1 -arg2 (etc) notice the -- after the dotnet arguments and before your program specific arguments.

GitHub问题

这篇关于在Visual Studio Code中使用命令行提示符运行C#程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆