调试时是否可以从目标目录启动外部程序?

时间:2021-05-17 20:59:29

When debugging I need to start an external program from the target directory of a build and am wondering if it can be accomplished using relative paths.

调试时,我需要从构建的目标目录启动外部程序,并想知道是否可以使用相对路径来完成。

As a post-build event I have the following:

作为一个后期制作活动,我有以下内容:

IF NOT "$(ConfigurationName)"=="Debug" GOTO End
:CopyExecutable
copy "$(SolutionDir)\Source\Lib\MyExecutable.exe" "$(TargetDir)"
:End

I need to run MyExecutable.exe when I am debugging so in the debug tab for the project properties I set "Start external program" to MyExecutable.exe but get a failure when running the debug. It seems I need to put the full path for this to work.

我需要在调试时运行MyExecutable.exe,因此在项目属性的调试选项卡中,我将“启动外部程序”设置为MyExecutable.exe,但在运行调试时出现故障。我似乎需要为此工作提供完整的路径。

Is there a way to do this using relative paths?

有没有办法使用相对路径来做到这一点?

3 个解决方案

#1


5  

The 'Start External Program' path is relative to your solution directory (in VS2005 anyway). So you could just put:

“启动外部程序”路径与您的解决方案目录相关(无论如何在VS2005中)。所以你可以放:

Source\Lib\MyExecutable.exe

I see you asked this a while ago, but I just ran into the same problem, and this is how I solved it.

我看到你刚才问过这个问题,但我遇到了同样的问题,这就是我解决它的方法。

#2


2  

(_Disclaimer: all directions are based on VS08. Things may be in different places in prior or future versions)

(_免责声明:所有方向都基于VS08。在以前或将来的版本中可能会有不同的地方)

I get the feeling that your other program is not a post-build step you need to run before debugging, but rather a program that also needs to run (a server or something) aswell while you debug.

我觉得你的其他程序不是你需要在调试之前运行的后构建步骤,而是在调试时也需要运行(服务器或其他东西)的程序。

Use an empty C++ Make-File project (you can use other project types, but this one by default does no actual building, so I find it's the easiest), and alter its start-up properties (Project/Properties -> Debug) to run your other application. Then, set your solution to start multiple projects (Solution/Properties -> Common Properties -> Startup Project).

使用一个空的C ++ Make-File项目(您可以使用其他项目类型,但默认情况下这个没有实际构建,因此我发现它是最简单的),并将其启动属性(项目/属性 - >调试)更改为运行你的其他应用程序然后,设置解决方案以启动多个项目(解决方案/属性 - >公共属性 - >启动项目)。

#3


-1  

Did you try something like $(TargetDir)\..\Lib ?

你尝试过像$(TargetDir)\ .. \ Lib这样的东西吗?

#1


5  

The 'Start External Program' path is relative to your solution directory (in VS2005 anyway). So you could just put:

“启动外部程序”路径与您的解决方案目录相关(无论如何在VS2005中)。所以你可以放:

Source\Lib\MyExecutable.exe

I see you asked this a while ago, but I just ran into the same problem, and this is how I solved it.

我看到你刚才问过这个问题,但我遇到了同样的问题,这就是我解决它的方法。

#2


2  

(_Disclaimer: all directions are based on VS08. Things may be in different places in prior or future versions)

(_免责声明:所有方向都基于VS08。在以前或将来的版本中可能会有不同的地方)

I get the feeling that your other program is not a post-build step you need to run before debugging, but rather a program that also needs to run (a server or something) aswell while you debug.

我觉得你的其他程序不是你需要在调试之前运行的后构建步骤,而是在调试时也需要运行(服务器或其他东西)的程序。

Use an empty C++ Make-File project (you can use other project types, but this one by default does no actual building, so I find it's the easiest), and alter its start-up properties (Project/Properties -> Debug) to run your other application. Then, set your solution to start multiple projects (Solution/Properties -> Common Properties -> Startup Project).

使用一个空的C ++ Make-File项目(您可以使用其他项目类型,但默认情况下这个没有实际构建,因此我发现它是最简单的),并将其启动属性(项目/属性 - >调试)更改为运行你的其他应用程序然后,设置解决方案以启动多个项目(解决方案/属性 - >公共属性 - >启动项目)。

#3


-1  

Did you try something like $(TargetDir)\..\Lib ?

你尝试过像$(TargetDir)\ .. \ Lib这样的东西吗?