Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Utility for Replacing web.config File Replacement Feature in Latest Versions of VS

5.00/5 (2 votes)
30 Jun 2016CPOL1 min read 6.9K   37  
Web.Config file replacement feature with VS2013 installer projects

Introduction

This tip gives you a small peice of utility code by which you can override your web.config file sections in pre build event. This will be helpful when you are using set and up and deployment projects in latest versions of VS with Installer Projects extension.

Background

While I was trying to port my existing web deployment projects from VS2008 to VS2013, I saw that Web.Config file replacement feature was not available with the installer plugins given here.

I didn't wanted to try new ways of publising web sites due to some constraints and wanted to reuse the existing setup and and deployment projects.

I have written this small piece of code which can be run as pre build event before you start building setup and deployment project.

Using the Code

All you need to do is to download the code and open command prompt and navigate to bin folder.

This folder contains sub folder with name configs with some sample cofigurations.

You can insert your settings in these files.

Place your web.config in this folder.

Run: ConfigReplacementTool.exe Web.Config appSettings Configs/appSettings.config connectionStrings Configs/connectionStrings.config serviceHostingEnvironment Configs/serviceHostingEnvironment.config compilation Configs/compilation.config customErrors Configs/customErrors.config mailSettings Configs/mailSettings.configdefaultProxy Configs/defaultProxy.config

Points of Interest

This is a simple workaround to make the existing setup and deployment project work.

History

  • 30th June, 2016: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)