Access to the path 'C:\Windows\system32\drivers\etc\hosts' is denied using MSBuild.ExtensionPack.Computer.HostsFile

May 19, 2011 at 9:57 AM
Edited May 22, 2011 at 10:46 AM


Firstly I'd like to say thanks for building MSBuild Extension Pack - it contains loads a very useful tasks.

I am attempting to set some DNS entries in the HOSTS file due to temporary absence of a DNS server using some MSBuild code as follows:

 <MSBuild.ExtensionPack.Computer.HostsFile TaskAction="SetHostEntry"
                                              Comment="The main load balanced address for TFS." />

This runs fine locally as a local desktop build but on the build server I am getting the following error: Access to the path 'C:\Windows\system32\drivers\etc\hosts' is denied

I am running this particular Team Build 2010 server on a separate Windows Server 2008 R2 machine. The Team Build user account is a local administrator due to the nightly build script creates user accounts, application pools etc so it needs elevated permissions.

If I log into the Build Server using the same Team Build server account I am able to edit the local HOSTS file successfully, just not as part of a build process.

Any help would be great.




May 19, 2011 at 1:03 PM
Edited May 22, 2011 at 10:42 AM

It turns out once I made changes to the tfs build service account - that is, I made it a member of the local administrators group, then restarted the Build Controller service, queued a build and it worked!

So it seems that the Build Controller caches permissions.


May 21, 2011 at 8:00 PM

Glad you got it working Simon. Thanks for reporting the solution.