Copy a config file from referenced dll

I have a two projects: main.exe and ref.dll. ref.dll also has two config files: ref.Settings.Debug.config and ref.Settings.Release.config. I want to copy right config file to output directory, but if I use postbuild copy command it just copies it into dll output debug/release folder, but doesn’t affect depended projects.

I tried to add fictive config file to project with Copy always parameter, and replace it with right config by this script:

copy /Y “$(ProjectDir)Settings.$(ConfigurationName).config” “$(ProjectDir)Settings.config”

but this soultion has some problems: VS after every build warns that file was modified outside of the source editor, fictive file could also be checked in in TFS, but its content is always changing, and sometimes it just doesn’t compile (post-build script fails).

How can I avoid all these problems? It’s important that
dependent project (main.exe in this example) shouldn’t know anything about referenced config files (so I cannot add another post-build script that copies config file from DLL output directory).


Source: dll

Leave a Reply