使用“启动外部程序"的相对路径在 VS.NET 2010 中 [英] Using relative path for "Start external program" in VS.NET 2010

查看:49
本文介绍了使用“启动外部程序"的相对路径在 VS.NET 2010 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过一些与此主题相关的帖子,但都没有给出任何确凿的答案...

I've seen a few posts related to this topic but none with any conclusive answers...

在调试我的 VS.NET 2010 应用程序时,我试图启动一个位置相对于项目路径的外部程序.我已经看到一些迹象表明 VS.NET 的早期版本支持宏(如 $(ProjectDir)),但它们似乎在 VS.NET 2010 中不起作用.使用相对路径表示法只会给我一个错误,即路径无效.

When debugging my VS.NET 2010 app, I'm trying to start an external program whose location is relative to the project path. I've seen some indications that macros (like $(ProjectDir)) were supported in earlier versions of VS.NET, but they don't seem to work in VS.NET 2010. Using relative path notation just gives me an error that the path is invalid.

有人遇到过这种情况吗?如果是这样,您是如何解决的?

Has anyone run into this? If so, how did you address?

谢谢.

推荐答案

找到答案 此处.

如果上面的链接失效了,总结如下:

In the event that the above link goes dead, the summarized answer is as follows:

  1. 宏在这里不起作用,所以忘记这一点.
  2. 环境变量也不起作用,所以也不要管它.
  3. 事实证明,Visual Studio.NET(至少在 2008 年和 2010 年)使用两个路径之一作为启动外部程序设置中指定的任何相对路径的基础...
  1. Macros don't work here, so forget about that.
  2. Environment variables don't work either, so forget about that as well.
  3. It turns out that Visual Studio.NET (at least 2008 and 2010) uses one of two paths as the base for any relative path specified in the Start external program setting...

如果 Visual Studio.NET 是通过单击资源管理器中的 SLN 文件启动的,则基本路径将是 SLN 所在的文件夹(包括\").一旦我修改了我的相对路径以解决这个问题,然后通过双击 SLN 文件启动 VS.NET 2010,我的外部程序在按 F5 时正确启动.

If Visual Studio.NET was launched by clicking on the SLN file in Explorer, the base path will be the folder (including the "\") where the SLN resides. Once I modified my relative path to account this and then launched VS.NET 2010 by double-clicking the SLN file, my external program correctly launched when hitting F5.

如果从开始"菜单上的快捷方式启动 Visual Studio.NET,然后从 Visual Studio.NET 中打开 SLN,则基本路径将是 [Visual Studio 安装路径]\Microsoft Visual Studio ["9.0" 或 "10.0" 取决于是使用 VS.NET 2008 还是 2010]\Common7\IDE\.

If Visual Studio.NET was launched from the shortcut on the Start Menu and then the SLN was opened from within Visual Studio.NET, the base path will be [Visual Studio install path]\Microsoft Visual Studio ["9.0" or "10.0" depending on whether using VS.NET 2008 or 2010]\Common7\IDE\.

我想现在说得通了,但 VS.NET 只能根据我启动 VS.NET 的方式正确找到我的外部程序,这仍然有点臭.

I guess it makes sense now, but it still kinda stinks that VS.NET will only find my external program correctly depending on how I launch VS.NET.

这篇关于使用“启动外部程序"的相对路径在 VS.NET 2010 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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