将应用程序配置文件复制到另一个应用程序目录
我正在测试 WCF 服务,该服务托管在控制台应用程序中。我正在使用 NUnit 运行测试。所以我想将控制台应用程序和控制台应用程序的app.config复制到测试程序集的Bin\Debug文件夹中。我可以通过添加对测试程序集的引用来复制控制台应用程序,但控制台应用程序的 app.config 不会出现。我也尝试通过设置属性来复制,但没有成功。它按原样复制 app.config,而不将名称更改为 ConsoleApp.exe.Config。有什么办法可以解决这个问题吗?
I am testing a WCF service, which is hosted in a console application. I am running the test using NUnit. So I want to copy the console application and app.config of console application to the Bin\Debug folder of the Test assembly. I am able to copy the console application, by adding the reference to the test assembly, but app.config of console application is not coming. Also I tried to copy by setting the properties, it not worked. It is copying the app.config as it is, it not changing the name as ConsoleApp.exe.Config. Is there any way to fix this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个生成后事件来执行此操作,该事件将复制项目 app.config 并将其重命名为 ConsoleApp.exe.config。
您还可以在项目中创建一个名为 ConsoleApp.exe.config 的文件,并用测试所需的配置填充它,并将其复制到输出目录。这将是我的首选解决方案,因为这意味着测试将控制配置,并且不会受到控制台应用程序项目中 app.config 的潜在更改的影响。
you can create a post build event to do this, which will copy the projects app.config and will rename it ConsoleApp.exe.config.
You could also just create a file in your project called ConsoleApp.exe.config and fill it with the config required for the tests and have it copy to the output directory. this would be my preferred solution as it would mean that the tests would be in control of the config and would not be affected by the potential changes to the app.config in the console applications project.