In one of my work projects I’ve made heavy use of unit tests, and in particular the integration of TestDriven.NET and Visual Studio .NET.
I keep all my tests in a separate assembly, but I need to make use of varying connections strings. The most obvious solution was to use an configuration key in an app.config file attached to the test project, but the projects was set to output a library (DLL), and VS.NET doesn’t automatically handle app.config files for libraries.
Now I could just create the file in my output directory and have it work, but a) that’s not very neat and b) being the good SCM user I am I don’t store build artifacts in subversion.
After a bit of a google, the most obvious solution was to use a Post-build Event to copy and rename the file for me like VS.NET should.
Here’s my variation of the solution:
copy "$(ProjectDir)app.config" "$(TargetDir)$(TargetFileName).config"