I haven't been a fan of Visual Studio Post-build command line events.
Problem:
We need to copy app.config during the build process and it needs to be mstest.exe.config in the test out directory. During our Unit Testing process on the build server we've been referencing a static class to provide all of our configurations. Now we are switching over to a real file. This makes all the unit tests referencing our configurations fail because System.Configuration.ConfigurationManager.GetSection returns null. The problem is our unit tests are being executed by MS test. Ideally we would maintain a configuration class reading from a file and a configuration class for testing which uses test values. Unfortunately due to time pressures that is not an option.
Solution:
By going into Visual Studio, project properties, Build Events Tab, Post-build event command line and typing copy "$(ProjectDir)app.config" "$(TargetDir)mstest.exe.config" /y
MSDN describes the $(ProjectDir) and $(TargetDir) variables
In our testrunconfig file we have a Deployment section and then a DeploymentItem with filename set to mstest.exe.config. My frist thought was to do the file copy on our build server after getting the source files and then have our testrunconfig file copy the mstest.exe.config using a DeploymentItem. Thinking about it for a minute I realized this would cause differences when we are building in Visual Studio and when we are building on the server which would easily cause confusion in the future.
Not to happy we are relying on the filesystem for our test, but happy that the build behaves the same on desktops and servers and anyone can figure out what is going on.
Tuesday, November 11, 2008
Subscribe to:
Post Comments (Atom)
2 comments:
Amiable brief and this enter helped me alot in my college assignement. Thanks you on your information.
Post a Comment