Yes you can do it. I just posted a blog on this http://sedodream.com/2012/02/14/HowToUpdateASingleFileUsingWebDeployMSDeploy.aspx , but I also copy the content below for you.
The other day I saw a question that was posted on StackOverflow asking if it is possible to update web.config using MSDeploy. I actually used a technique where I updated one file in one of my previous posts in How to disable your web application at the time of publication , but it was not called too much. In any case, I will show you how you can update a single file (in this case web.config) using MSDeploy.
You can use the contentPath provider to facilitate updating a single file. With contentPath, you can sync a single file or an entire folder. You can also use the IIS application paths to resolve where the file / folder is located. For example, if I have a web.config file in a local folder named "C: \ Data \ Personal \ My Repo \ sayed-samples \ UpdateWebConfig" and I want to update my IIS website UpdateWebCfg running on the default website in My folder I would use the command shown below.
%msdeploy% -verb:sync -source:contentPath="C:\Data\Personal\My Repo\sayed-samples\UpdateWebConfig\web.config" -dest:contentPath="Default Web Site/UpdateWebCfg/web.config"
From the command above, you can see that I set the path to the source content to the local file and the path to the final content using the IIS path {SiteName} / {AppName} / {file-path}. In this case, I update the site running in IIS on my local machine. To update the one that is running on the remote computer, you will need to add the computer_name and possibly some other values ββto the -dest argument.
You can view the latest sources of this example in my github repo .
source share