Friday, 23 January 2015

How can I easily have different app.config files for different build configurations in MSBUILD?

There are a few different proposed solutions I have seen suggested, some including recommendations involving 3rd party tools and Visual Studio Transformation Extensions. The following is the simplest method I have found. It involves a violation of the DRY principle (Don't Repeat Yourself) as the app.config files are duplicated (due to the lack of transforms) - but I considered this to be a small sacrifice based on the simplicity of the solution.

Steps:
1) Unload your Project file (csproj) file in Visual Studio and Right click and select "Edit {My Project Name}.csproj" on that same file to edit it.
2) Add a folder for each MSBUILD configuration that you want and put your different App.Config files in those subfolders e.g. \Release\App.config and \Debug\App.Config
2) Find the section in your csproj project file <None Include="App.config" /> and replace it with the following conditional Include statements for each of your MSBUILD configurations:
<None Condition=" '$(Configuration)' == 'Debug' " Include="Debug\App.config" />
<None Condition=" '$(Configuration)' == 'Release' " Include="Release\App.config" />

When you build, it will use either of the application configuration files that you have created and put them in the relevant build configuration output directory.

DDK

16 comments:

Anonymous said...

Hey did you hear about Togaf Training ? TOGAF Certification is one of the top 10 in demand skills in technology, and people with that skill are making money or more. Learn how to get certified quickly and give wings to your carrer.‬

Devi.Angularjs said...

I have read your blog its very attractive and impressive. I like it your blog.

.Net Training in Chennai | .Net Online Training

Dot Net Online Training | LINQ Online Training ASP.NET Online Training

Pradeep Appslure said...

Mobile app development company in Canada

callgirlsingurgaon said...

Rice Packaging Bags Manufacturers
Pouch Manufacturers

callgirlsingurgaon said...

we have provide the best ppc service in Gurgaon.
ppc services in gurgaon
website designing company in Gurgaon
PPC Expert For Technical Support

callgirlsingurgaon said...

we have provide the best fridge repair service.
fridge repair in faridabad
Bosch Fridge Repair in Faridabad
Godrej Fridge Repair in Faridabad
Haier Fridge Repair in Faridabad
Videocon Fridge Repair in Faridabad

callgirlsingurgaon said...

Bali Honeymoon Packages From Delhi
Bali Honeymoon Packages From Chennai
Hong Kong Packages From Delhi
Europe Packages from Delhi

IT Tutorials said...

Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement | UiPath training in Chennai | UiPath Chennai

Rithi Rawat said...

Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.

machine learning training in chennai
artificial intelligence and machine learning course in chennai
big data course in chennai
big data training and placement in chennai

Email support said...


Nice blog thanks for sharing with us

forgot yahoo password

forgot aol password

forgot outlook password

at&t phone password reset

forgot roadrunner password





شوشو said...

شركة مكافحة حشرات بحائل
شركة مكافحة حشرات بالدمام
شركة دهانات بأبها
افضل شركة ترميم وتشطيب المنازل بالجنوب

IT Tutorials said...


Get the most advanced Hadoop Course by Professional expert. Just attend a FREE Demo session.
call us @ 9884412301 | 9600112302
Hadoop training in chennai | Hadoop training in velachery

meldaresearch said...

Do you where to find quality Custom Term Paper Writing Services to suit all your academic requirements? Legitimate Term Paper Writing Services are there for all your Custom Term Paper Writing Service needs.

Pradeep Appslure said...

Appslure is a Brilliant mobile Application Development Company in Gurgaon. Our app developers team are expert in iOS, Android, iPhone
Mobile app development company in gurgaon

Nisha Sharma said...

Mobile app development in mumbai

Dr Babita said...

Thanks for provide great informatic and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you once agian
we offer services delhi birth certificate which inculde name inclusion in birth certificate and birth certificate correction complete process is online and we offer
birth certificate apply online and we offer this birth certificate online same service offers at yourdoorstep at birth certificate in ghaziabad our dream to provide birth certificate in india and other staes like birth certificate in bengaluru and birth certificate in gurgaon book service with us birth certificate in noida also, service at yoursdoorstep only birth certificate in india or