Deploy the right app.config every time with build events

22. May 2009

It’s been a while since i have been “searching” build events but recently i made a mistake in creating setup for a customer by packing my own app.config so i have to do this all over again(poor me) so i decided to find a way to deploy the "right” app.config file every time.

Of course you can use many apps/procedures to do this and in large teams you can use servers just for this thing (along with unit testing and stuff of course …) but for a poor developer like me which comes from the all-time-classic-keeping-things-simple-DOS-age this is the most sufficient solution. Here it goes(i suppose you have a windows project with a app.config file ready)…

 

Create a app_deploy.config file in project directory

 

test1

 

then while app_deploy.config is selected go to properties (F4) and change the “Do not copy” property to “Copy if newer”

 

test2

 

after that right click on project and select “Properties”, select “Build Events” tab and push the “edit post-build” button

 

test3

 

finally you can write this script into the window (or you can write your own DOS-like scripts using the macros described there)

IF $(ConfigurationName) == Debug GOTO end
md c:\Build\TestProject
copy $(TargetPath) c:\Build\TestProject
copy $(TargetDir)app_deploy.config c:\Build\TestProject\$(ProjectName).exe.config
copy $(TargetDir)*.dll c:\Build\TestProject
:end

 

this line is checking that it isn’t debug mode

IF $(ConfigurationName) == Debug GOTO end

second line makes a build directory

md c:\Build\TestProject

the third line copies the .exe file to output directory

copy $(TargetPath) c:\Build\TestProject

the forth line deploy our configuration file and rename's it to match the exe file

copy $(TargetDir)app_deploy.config c:\Build\TestProject\$(ProjectName).exe.config

the fifth line copies the necessary dll’s that application requires

copy $(TargetDir)*.dll c:\Build\TestProject

and the last is the “escape” line of the debug mode

 

after this you can build your project in any other mode than debug and then the “deployable” files in c:\Build\TestProject

 

Thank you for reading this and see you soon!!!

Bookmark and Share DotnetKicks dotnetshoutout

General, Visual Studio, Build , , ,

Comments

5/25/2009 4:08:50 PM #
Deploy the right app.config every time with build events

You've been kicked (a good thing) - Trackback from DotNetKicks.com
5/25/2009 4:49:11 PM #
stelios - Deploy the right app.config every time with build events

Thank you for submitting this cool story - Trackback from DotNetShoutout
Joe
7/9/2009 11:07:14 AM #
Nice blog.. really like it..
7/17/2009 7:01:56 PM #
Great post - Just subscriped to your RSS feed.. Thanks
7/18/2009 5:53:11 AM #
thank you!

Hope my "findings" help you!
9/20/2009 11:28:15 AM #
I digged this for more news from you.



Regards and respect
James
9/20/2009 11:28:16 AM #
Wonder full writing skills you got mate.


Regards
Mathu
10/23/2009 9:14:19 PM #
can we place the app.config file in different folder other than root in .net 2003?
10/23/2009 9:31:07 PM #
ofcourse, assume that the directory is "configdir", just replace this line
copy $(TargetDir)app_deploy.config c:\Build\TestProject\$(ProjectName).exe.config
with this line
copy $(TargetDir)\configdir\app_deploy.config c:\Build\TestProject\$(ProjectName).exe.config
11/29/2009 3:54:24 PM #
I recently came across your blog and have been reading along. I want to express my admiration of your writing skill and ability to make reader to read the while thing to the end. I would like to read more of your blogs and to share my thoughts with you.
12/11/2009 10:19:25 PM #
Nice post . keep up the good work
12/17/2009 7:21:22 AM #
streets to predict how many people (pedestrians or vehicles) come to the individual spaces or streets.Thanks for sharing this article.
12/18/2009 2:33:31 PM #
Do you have any more info on this?
12/25/2009 8:18:26 AM #
Articles and content in this section of the website are really amazing.
1/21/2010 4:13:31 AM #
You have to have your heart in the business and the business in your heart.
1/23/2010 3:22:00 PM #
What is once well done is done forever.
1/24/2010 8:04:13 AM #
I will right away grab your rss feed to stay informed of any updates.
1/27/2010 3:09:07 AM #
It's always too soon to quit.
1/29/2010 2:19:37 AM #
This a little bit funny. I found your site via search engine a few moment ago, and luckily, this is the only information I was looking for the last hours.
1/31/2010 6:05:59 PM #
I've surfed the net more than three hours today, however, I haven't found such useful information like yours. Thanks a lot, it's really useful for me.
2/2/2010 5:15:26 AM #
I'll grab your rss feed right now, I like this kind of post! Thomas
2/3/2010 12:02:11 AM #
The true worth of a man is to be measured by the objects he pursues.
2/10/2010 12:50:46 PM #
I've surfed the net more than three hours today, however, I haven't found such useful information like yours. Thanks a lot, it's really useful for me.
2/10/2010 1:18:51 PM #
Action itself, so long as I am convinced that it is right action, gives me satisfaction.
2/15/2010 9:39:15 AM #
Thanks for sharing.
2/15/2010 6:42:11 PM #
Action itself, so long as I am convinced that it is right action, gives me satisfaction.
2/16/2010 8:06:47 AM #
i would say one thing that you are a true blogger
2/17/2010 2:55:22 PM #
That's Too nice, when it comes in india hope it can make a Rocking place for youngster.. hope that come true.
2/18/2010 12:11:01 PM #
Whether you think you can or whether you think you can't, you're right!
2/18/2010 6:10:08 PM #
This is a good piece of writing, I located your site browsing aol for a related content and came to this. I couldnt get to much alternative info on this blog post, so it was wonderful to find this one. I will certainly end up being returning to check out some other articles that you have another time.
2/20/2010 4:06:00 AM #
Hello, great day.. Your work is quite striking. I never imagined that it was possible to carry out something like that until after I checked out your content. You definitely gave an incredible perception on how this whole process works. Ill make sure to come back for more advice. Keep writing!
2/20/2010 10:51:58 AM #
I don't agree with everything in this write-up, but you do make some very good points. Im very interested in this matter and I myself do alot of research as well. Either way it was a well thoughtout and nice read so I figured I would leave you a comment. Feel free to check out my website sometime and let me know what you think.
2/21/2010 12:23:24 AM #
This is a good post, I was wondering if I could use this blog post on my website, I will link it back to your website though. If this is a problem please let me know and I will take it down right away.
2/21/2010 2:45:57 PM #
I really enjoyed read your article, very interesting ...
2/21/2010 7:06:44 PM #
Thank you for caring to share this with readers, will be back for more!
2/22/2010 6:23:37 PM #
This is a good write-up, I was wondering if I could use this summary on my website, I will link it back to your website though. If this is a problem please let me know and I will take it down right away.
2/22/2010 6:54:36 PM #
Dear guys, I've surfed the net more than three hours today, however, I haven't found such useful information like yours. Thanks a lot, it's really useful for me.
2/23/2010 6:15:23 AM #
Terrific summary, this is very similar to a site that I have. Please check it out sometime and feel free to leave me a comenet on it and tell me what you think. Im always looking for feedback.
2/24/2010 12:14:43 AM #
Hiya . I discovered this website by mistake. I was searching in Google for beach vacations for my trip when I found your website, I have to say your internet site is pretty cool I just love the theme, its amazing!. I don't have the time at this time to fully read your entire web page but I bookmarked it and also will sign up for your RSS feed. I'll be back around in a couple of days. Thanks for the cool site.
SEO
2/25/2010 3:42:44 PM #
Great blog post. It's useful information.
2/25/2010 7:34:56 PM #
Beds  Beds  Beds  Beds  Beds  Beds  Beds  Beds  Beds  .
2/26/2010 3:00:52 AM #
I don't agree with everything in this article, but you do make some very good points. Im very interested in this matter and I myself do alot of research as well. Either way it was a well thoughtout and nice read so I figured I would leave you a comment. Feel free to check out my website sometime and let me know what you think.
2/26/2010 3:47:17 AM #
Many thanks for the marvelous blog posting! I found your post very interesting, I believe you are a marvelous writer. I just bookmarked your blog and come back quite soon. I want to encourage you to continue that marvelous job, I hope you will have a nice day!
2/26/2010 1:19:50 PM #
Fantastic site, where did you come up with the info in this blog post? I'm glad I found it though, ill be checking back soon to see what other articles you have.
2/26/2010 2:04:36 PM #
Thanks for this posting! I truly like it. This might be the wrong place to ask this, but I will need support. I'm quite a new comer to travel. I've had a phobia on the topic area, these days I need to face my anxieties. Try as I might, I cannot discover where to start on the subject. Would you point a travel-challenged beginner inside the correct direction? Where must i begin in wrappy my head around all this?