如何更改调试时在Visual Studio中的工作目录? [英] How to change the working directory while debugging in Visual Studio?

查看:1754
本文介绍了如何更改调试时在Visual Studio中的工作目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio中的Windows窗体项目,从同一个解决方案中的其他项目中读取配置文件。一旦部署该应用程序会从该解决方案的根文件夹中运行的文件会被从类似/Project1/connection.config读

I have a windows form project in Visual Studio that reads configuration files from an other project in the same solution. Once deployed this application will run from the root folder for the solution and the files will then be read from something like "/Project1/connection.config".

当我不过调试窗体的应用程序,并得到执行的程序集路径,它将从斌/调试或斌/释放运行ERGO的路径配置文件是不同的。

When I however debug the forms application and get the executing assembly path it will run from "bin/Debug" or "bin/Release" ergo the path to the configuration files is different.

有没有办法告诉Visual Studio中无论是调试,从不同的路径应用程序或只是复制应用程序一次编译和调试/从同一个路径中运行它,因为它会从在部署后运行?

Is there a way to tell Visual Studio either debug the application from a different path or just copy the application once compiled and debug/run it from the same path as it will be run from once it is deployed?

推荐答案

在您的项目配置文件移动到调试生成目录设置后生成事件。

Set a post build event on your project to move the config file into the debug build directory.

右键单击该项目,将需要一个不同的项目,然后选择属性的配置,然后单击生成事件选项卡上,并添加后生成事件是这样的:

Right click on the project that will require the config from a different project and select properties, then click on the build events tab and add a post build event something like this:

复制configFilePath $(TARGETPATH​​)

Copy configFilePath $(TargetPath)

这篇关于如何更改调试时在Visual Studio中的工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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