Visual Studio:管理应用程序的调试命令行参数 [英] Visual Studio: Manage debugging command line arguments for the app

查看:93
本文介绍了Visual Studio:管理应用程序的调试命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中,是否有任何简单的方法来管理C ++项目的命令行参数(我想对于C#也是一样),就像它在Visual Studio Code中一样,在其中您可以使用不同的运行预设进行下拉菜单?我正在开发CLI,需要经常更改参数.现在,我必须复制从txt文件粘贴它们.我想这不是解决这个问题的最简单方法:)

Is there any simple way to manage command line arguments for C++ project (I suppose the same for C#) in Visual Studio like it works in Visual Studio Code where you have dropdown with different run presets? I'm developing CLI and need to change arguments pretty often. Now I have to copy paste them from txt file. I guess it's not the easiest way to handle this :)

UPD:只是为了澄清一下,我是在谈论控制台应用程序项目属性->调试->命令参数块.

UPD: Just to clarify I'm speaking about Console application project properties -> Debugging -> Command Arguments block.

推荐答案

您可以将以下命令用于 VisualCommander 为选定的C ++启动项目设置命令行参数并开始调试:

You can use the following command for Visual Commander to set command line arguments for a selected C++ startup project and start debugging:

(语言:C#,引用:Microsoft.VisualStudio.VCProjectEngine)

(Language: C#, References: Microsoft.VisualStudio.VCProjectEngine)

using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.VCProjectEngine;

public class C : VisualCommanderExt.ICommand
{
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
    {
        Project startupProject = DTE.Solution.Item(((DTE.Solution.SolutionBuild as SolutionBuild2).StartupProjects as object[])[0]);
        VCProject vcproj = startupProject.Object as VCProject;
        VCConfiguration vcconfig = vcproj.ActiveConfiguration;
        VCDebugSettings vcdebug = vcconfig.DebugSettings as VCDebugSettings;
        vcdebug.CommandArguments = "my_arguments_1";
        DTE.ExecuteCommand("Debug.Start");
    }
}

具有多个带有不同参数的此类命令,您可以从VCmd菜单中快速选择并运行它们.

Having several such commands with different arguments, you can quickly select and run them from the VCmd menu.

这篇关于Visual Studio:管理应用程序的调试命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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