« TestDriven.net and VS 2005 | Main | .NET vs. Java? It's All About Choice »

2005.09.07

Comments

Jason C
In your #2 item above, the post-build command text should be this: copy /Y $(ProjectDir)app.config $(TargetPath).config
Todd Girvin
Thanks, Jason. I don't know how my original post got so non-functional. But I've corrected it with your feedback.
Todd Girvin
I found another related blog entry that says you just have to name your config file properly. I'll try it out when I have a chance and confirm. http://blog.u2u.info/DottextWeb/peter/archive/2005/07/13/6179.aspx
Gerard
This is all good stuff but what is needed is on top of this is: 1. The ability to add build events to web based projects in VS2005. There is no concept of a project any more for VS 2005 web projects (both web clients and web services). 2. The ability to generate the config file for each user from an XML document (for example). This is a simple find/replace dependent on environment. Some inheritance in the data would be good as different users may have the same environemnt topology for some solutions. I wish a SourceForge or GotDotNet project would handle this. Maybe there already is one. Anyone know ???
Todd Girvin
Gerard, there is already a Web Application Project plug-in being developed here: http://webproject.scottgu.com/
Jim Lesch
Problem: Unit tests fail when they depend upon a config file for another project in your solution. Proposed Solution #1: In each test project, create an App.config file with your AppSettings you'd normally put in Web.config or your main executable's config file. In your test project's properties pane, select Build Event and add this line to your post-build command line: copy /Y $(ProjectDir)app.config $(TargetPath).config Problem with solution #1: Not intuitive when you have a web.config format and transferring it to an app.config format. You also have 2 files to maintain when there is a change. Proposed Solution #2: Copy the config file into your test project output (bin) directory and rename it to YourTestAssembly.dll.config. Now you get all the config settings and you also get it copied automatically for you. Problem with solution #2: You still have to maintain 2 config files! Solution #3: Each time you build a Pre-Build event copies the master config file to the Test ouput dir and renames it using the .dll.config convention. On the deploy, you get an up to date config file but you only have to change it in one place – the source project. This is the full line in the Pre-Build event command line: copy $(SolutionDir)\Web16\web.config $(TargetDir)\$(TargetFileName).config Problem with this solution: The source project and config file name are hardcoded. You could use some kind of naming convention to make it work. it also assumes you have a 1-1 relationship between projects and test projects.
Brandon
For paths that contain spaces, the post-build command should be adjusted to copy /Y "$(ProjectDir)app.config" "$(TargetPath).config" Enjoy!
Mordy
I was just about to give up and hard code it within a #IF (DEBUG), thank god I found this post in time :)

The comments to this entry are closed.

November 2008

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Blog powered by Typepad

We Like