VS2013 - 如何在使用外部程序的 C# 项目的命令行参数中传递解决方案文件夹 $(SolutionDir) [英] VS2013 - How to pass the solution folder, $(SolutionDir), in the command line arguments for a C# project using an external program

查看:23
本文介绍了VS2013 - 如何在使用外部程序的 C# 项目的命令行参数中传递解决方案文件夹 $(SolutionDir)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Excel 添加 C#.为了调试它,我需要使用包含插件的调试或发布路径的命令行参数启动 Excel.exe.

I am building a C# adding for Excel. In order to debug it, I need to launch Excel.exe with a command line argument containing the Debug or Release path to the addin.

例如:

  • 启动外部程序:C:\Program Files\Microsoft Office\Office15\EXCEL.EXE
  • 命令行参数C:\Dev\Project1\Project1\bin\Debug\Project1-AddIn64.xll"

但是,对于 VS 中的 C++ 项目,我想用等效的 $(SolutionDir) 替换C:\Dev\Project1\Project1\bin\Debug".有没有办法做到这一点 ?如果它不可行,有没有办法解决这个问题?

However, I would like to replace "C:\Dev\Project1\Project1\bin\Debug" with an equivalent of $(SolutionDir) for C++ projects in VS. Is there a way to do this ? If it is not doable, is there a way to get around this ?

请支持我并通过投票支持以下想法将其添加到 VS 中:http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6350738-support-for-macros-in-调试命令行参数

please support me and get this added in VS by voting up the following idea: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6350738-support-for-macros-in-debugging-command-line-argum

推荐答案

确实,开始选项中不能使用宏 |命令行参数

Indeed, the macros cannot be used in the Start Options | Command line arguments

我看到了两种解决方案:

I see two solutions:

  1. 由于当前文件夹设置为 $(TargetDir),当您启动一个应用程序时,您可以像这样引用解决方案文件夹:..\..\..\ 如果外部程序接受相对路径.(我不太确定你为什么要引用解决方案文件夹,引用输出/目标文件夹对我来说更有意义)

  1. As the current folder is set to the $(TargetDir) when you Start an application you could refer to the solution folder like this: ..\..\..\ if the External program accepts a relative path. (I am not quite sure why you would ever want to refer to the solution folder, referring to the output/target folder makes more sense to me)

在构建后事件(取消注册)中,并按照部署组件时应注册的方式注册组件(正确的设置).这样您只需在开始操作中引用 Excel.这也立即增加了测试与生产更相似的场景的好处.

In the Post Build event (unregister) and register the component the way the component should be registered when deploying it (a proper setup). This way you only have to refer to Excel in the Start Action. This also immediately adds the benefit of testing a scenario that is more similar to production.

这篇关于VS2013 - 如何在使用外部程序的 C# 项目的命令行参数中传递解决方案文件夹 $(SolutionDir)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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