views:

276

answers:

3

I have a solution which has 3 projects. One is a console app and other 2 are windows applications. Both windows applications uses console application so I added the reference of console application in both windows app projects. Now when I build windows projects, console application is being copied in output directory but the problem is that its config file "consoleapp.exe.config" is not being copied!

If I would have used a library (assembly) instead of console application, it would created the config file of that assembly in output folder.

How to solve this problem?

+2  A: 

Try this:

  1. Select consoleapp.exe.config in solution tree.

  2. Select "Content" for Build Action option in property grid.

  3. Select Copy always for Copy to Output Directory option.

Hope this helps you :)

TheVillageIdiot
There is no consoleapp.exe.config file in solution tree. Project contains app.config file which is renamed to consoleapp.exe.config while building the project. I tried your steps with app.config and it does copy it to output but I want it to be renamed to consoleapp.exe.config also.
Hemant
A: 

Quickly creating a console project in VS2008 and adding an "App.config", it has settings:

Build Action: None
Copy to Ouput Directory: Do not copy
Custom Tool: <blank>
Custom Tool Namespace: <blank>

However I'm not sure what effect adding a reference to the console project will have, as a console project is an application rather than class library.

If you want the console application to start up with the Windows applications for debugging, then a better approach than project references would be to set the solution to start multiple applications. Right click on the solution, select properties and on the Start Project node, select multiple projects. (And remove the references to the console application.)

Richard
A: 

Your applications are using the default values for your settings from the compiled code of the referenced project.

You should copy your app.config from the other projects (or at least copy the settings that you want to be able to change) to the calling project, and then when the application compiles you will have an [YourAppName].exe.config that you can modify.

All this happens because an app domain in C# can have only one assembly level app.config file. Here's more information on MSDN.

Even Mien