Tuesday, May 10, 2011

What's new in VS2010



Web.Config Transformation


As we all know that Web.config in Dev environment is never same in Test and Prod environment. We have to replace couple of entries like Connection string etc. for Test and Prod.

VS2010 gives an excellent feature called as Web.Config Transformation to automate these changes. Let's see here how it is done.

1. Open Configuration Manager from Build menu.
2. Create a new Config file using Configuration Manager -> New
3. Lets name it as MyTransform.
4. Right click on the Web.Config file and select Add Config Transform. VS2010 will
create web.MyTransform.config file. This is the file where we will make our Prod entries.
5. Open the Web.Config file and add following entries.





6. Add the production entries in the web.MyTransform.config file as follows





7. For testing purpose, let's create an Application under Default Web Site on our local box. Let's assume this as Prod Url.
8. Now publish your Web Application to your Prod Url by Right click on Project and choose Publish.
9. Open the Physical path of the Prod Url and check the Web.Config file. You will find the "ProdBox" for the "ServerName" key in the appSettings section.

No comments:

Post a Comment