Home Dashboard Directory Help

TransformXml Task locks config file identified in Source attribute by Alex Hildyard



Sign in
to vote
Type: Bug
ID: 562200
Opened: 5/27/2010 8:08:34 AM
Access Restriction: Public
User(s) can reproduce this bug


I believe there is a problem with the MSBuild TransformXml task, namely that once run it fails to close the handle on the input file (“Source” attribute), rendering it undeletable. As a result, it isn't possible to deploy to the same directory more than once, since the open file handle prevents the file from being overwritten.

The best workaround I've found is to create a temporary file, and transform that.

I enclose a brief example below.

Thanks a lot,


<<Target Name="X">


        <!-- Copy the Web.config, because TransformXml locks it -->
        <Copy SourceFiles="Web.config" DestinationFiles="$(TempFile)"/>

        <!-- Mark up web.config file, and copy it back -->
        <TransformXml Source="$(TempFile)" Transform="Web.DevTest.config" Destination="Web.config" />

        <!-- Uh oh ... -->
        <Delete Files="$(TempFile)"/>
Sign in to post a comment.
Posted by Microsoft on 10/18/2012 at 3:16 PM
Thanks for reporting the issue. The issue is now fixed in Visual Studio 2012 RTM.
Posted by molafish on 3/24/2011 at 2:58 PM
It also seems to lock the Transform file. I have to use a temp file there as well in order to delete the transform file afterwards.
Posted by jpettys1 on 3/8/2011 at 2:34 PM
It's been over nine months - looks like no one has followed through on Chuck's statement that someone would respond to this issue. Maybe dropping this comment in will ping someone within MS to take another look at it. We just got hit by it today and are using Alex's work-around. Thanks, Alex!
Posted by Simon Crowell on 7/21/2010 at 11:02 PM
I am also having the same issue, sorry to be annoying and post the same comments as others, but is there an ETA on a resolution?

My current workaround is simply manually deleting and renaming files locked by the process after the build has finished. This is the only bottle neck in an other wise pretty slick build deployment process.

Posted by Microsoft on 6/3/2010 at 4:07 PM
We are currently investigating the issue. Someone will respond once we have done some analysis or need more information.

Chuck England
Visual Studio Platform
Program Manager - MSBuild
Posted by --F on 6/2/2010 at 3:24 PM
I'm experiencing this very same issue. Any eta on resolution??
Posted by Microsoft on 6/1/2010 at 6:09 PM
Thank you for reporting the issue.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.These specialized experts will follow-up with your issue.
Posted by Chuckie on 5/29/2010 at 1:13 AM
I am experiencing the same issue. I have yet to find a work around.
Posted by Microsoft on 5/27/2010 at 5:05 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by HugeHugh on 2/23/2012 at 8:06 AM
I'm unable to get this workaround to work. <DeleteAfterBuild> isn't an actual MSBuild command it is just the name of a variable in that SO post.
Posted by HugeHugh on 2/21/2012 at 2:04 PM
Try using <DeleteAfterBuild> instead of <Delete>.

Example can be found here: