11 Comments

  • My VB.Net application creates and uses a config File.

    Now I am at cleint site and when I build my project my .config gets deleted from the Bin folder.

    I even copy it to bin folder and add to project but it gets deleted on build.



    I doubt if it something withthe .Net Dev Env version.. i m using .Net 1.1 now.

    When I add a new application Configuration File from my project, rename it to my application name and build it gets deleted from bin folder.

    Can you help me with this, why this is happening ?



    Waiting for your response.

    Please respond at : ritesh.arora@ubs.com



    Regards,

    Ritesh

  • Hi Ritish,



    You probably know this by now...



    Version 1.1. of the .NET environment will delete your app.config file each time you compile the code. Instead, add a file called app.config to your project and this will be copied in each time to the debug/release folders.

  • I have run into the same problem. I have added a file to the project named app.config and it does not get copied to bin/debug. I've tried various things from adding an XML file named app.config to adding an application configuration file (another file type option) named app.config. Then, I do a rebuild solution. I check the debug folder and the config file is not there. (no, not one named applicationname.exe.config either). There must be something we're missing.



    Any help is appreciated.



    -Tony

  • Ivan,



    thaz a coooool info.............thnx

  • Again, no config file is copied to the debug folder.



    Now, if I am doing a release, it's there (in the release folder). But when I'm compiling in debug mode, it does not get coppied to the debug folder.



    -Tony

  • try using a post-build event in the project's properties window. something like this should do the trick

    copy /Y ${projectdir}\app.config ${outputdir}\appname.exe.config



    that will copy the app.config to the build dir everytime the project is built.





    -ChazZ

  • can i have multiple app.config files in a solution , if so how to read them at their level?

  • I had an out of date lesson book, and this thing really bit me on the butt.

    Thanks for the tip.

  • You need to change the Build Action to "Content" if you want the file copied to the build target folder. Otherwise, it's just considered a developer artifact and no action will be taken.

  • This tip works in VS 2003, in 2005 you don't need it.

  • (VB2005) what about when you want to maintain 2 separate versions of app.config for both DEBUG and RELEASE? Ideally I just want to switch the build config to Release and get the alternative myapp.exe.config in the resulting package. I've tried everything I can think of, as 2 separate content files (using exclude filters), you can't change the target folder or name!

    As just 'files' added to the build, you can rename the target (so debug.config can become myapp.exe.config) but you can't specify the applicable build config (Active/Debug/Release), so you need to manually exclude/include each file .

    I just want to be able to have debug.config and release.config files in the source code, and for the appropriate one to be included in the build when I switch the configuration between Debug and Release. I can't beleive it's so tricky - I must be missing something obvious. Any Ideas anyone?

Comments have been disabled for this content.