Passing command line parameters with Visual Studio

2019-01-07 21:00发布

问题:

How do I set the command line arguments for an application I am developing using Visual Studio , it is a console application. I've done this on eclipse, is there a similar option on Visual Studio?

回答1:

Something must be wrong with your Visual Studio if you don't see Command Line Arguments.

If you can't fix your Visual Studio, 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>


回答2:

I would like just to add that menu shown on the picture could be accessed via Visual Studio 2010 Project Menu, then all the way down to the your project name properties.