I am using MSBuld task to change the virtual directory of an IIS Site hosted on windows 2012 server. I am using following code:
<MSBuild.ExtensionPack.Web.Iis7Website TaskAction="Stop"
Name="TestSite"
MachineName="$(MachineName)"/>
<MSBuild.ExtensionPack.Web.Iis7Website TaskAction="ModifyPath"
Name="TestSite"
Path="$(PublishDir)"
MachineName="$(MachineName)"/>
<MSBuild.ExtensionPack.Web.Iis7Website TaskAction="Start"
Name="TestSite"
MachineName="$(MachineName)"/>
I am performing two task:
I am getting following error when I try to change the virtual directory of a IIS site either on same machine or on different machine.
UnauthorizedAccessException: Retrieving the COM class factory for remote component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} from machine XXXX failed due to the following error: 80070005
I am using same code on windows 2008 server to change virtual directory path of another website hosted on a different machine & it is working fine.
I looked around for similar issue & most of the people talking about suing user-name and password of a person having admin right other machine or make some changes in registry. I do not want to use these two approaches.
Is there any other work around?
As it turned out, I was running the task using Team City (continuous integration server) which in turn used ms-build task to change the virtual directory. Team city was running under a service account. I had to add that service account under Administrators group on the remote machine.