32

How do I set the command line arguments for a console application I am debugging in Visual Studio? I've done this in Eclipse, is there a similar option in Visual Studio?

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Aadi Droid
  • 1,689
  • 4
  • 22
  • 46

3 Answers3

54

Command Line Arguments can be set in the Debug tag in the project's Properties window:

enter image description here

Alternatively, there is an option to add StartArguments element to your .csproj.user file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishUrlHistory />
    <InstallUrlHistory />
    <SupportUrlHistory />
    <UpdateUrlHistory />
    <BootstrapperUrlHistory />
    <ErrorReportUrlHistory />
    <FallbackCulture>en-US</FallbackCulture>
    <VerifyUploadedFiles>false</VerifyUploadedFiles>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <StartArguments>Argument1 Argument2</StartArguments>   <<== THIS LINE
  </PropertyGroup>
</Project>
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Alex Aza
  • 76,499
  • 26
  • 155
  • 134
  • 3
    Is it possible to use named parameters for when using libraries like command line parser? e.g. How can I pass something like `-url https://google.com -p pass -u user`? – Animesh Jan 29 '18 at 10:48
4

Visual studio 2022 , this screenshot explain all steps

enter image description here

HO LI Pin
  • 1,441
  • 13
  • 13
2

In 2020, if you are now using VSCode, you can set the arguments in the lauch.json file.

 "version": "0.2.0",
"configurations": [
    {
        "name": ".NET Core Launch (console)",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",
        "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CreatePRUDFileClient.dll",
        "args": [argument1, argument2, argument3],
        "cwd": "${workspaceFolder}",
        "console": "internalConsole",
        "stopAtEntry": false
    },
    {
        "name": ".NET Core Attach",
        "type": "coreclr",
        "request": "attach",
        "processId": "${command:pickProcess}"
    }
]