Using MSBuild to deploy a website cross-domain
The task: to have an automated build process which would take the fresh built files and deploy them on a remote web server.
The challenge: the remote web server was not in the same domain as the machine with Team Build on it.
Initial research found plenty of helpful advice on how to do a copy using the <Copy> task. I tried various different methods of specifying the files I wanted to copy but all hit the same trouble. I tried adding on some community extensions to MSBuild to FTP Copy but didn’t get far with that as it seemed to want to transfer only one file at a time.
In the end, our Operations Team came up with the answer in the form of a Trust Relationship between the two domains in question. Now, my share was browsable without needing to enter remote domain credentials.
So the Target I wrote overwrites the behaviour of the ‘AfterDropBuild’ target and looks something like this:
<Target Name="AfterDropBuild">
<CreateItem Include="$(DropLocation)\$(BuildNumber)\Release\_PublishedWebsites\PROJECT\**\*.*">
<Output ItemName="ItemsToDeploy" TaskParameter="Include"/>
</CreateItem>
<Message Text="Found items: @(ItemsToDeploy,'%0d%0a')" Importance="high"/>
<Copy SourceFiles="@(ItemsToDeploy)" DestinationFiles="@(ItemsToDeploy->'\\REMOTESERVERIP\PROJECTDROPSHARE\%(RecursiveDir)%(Filename)%(Extension)')" /> </Target>
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.



Comments
No comments yet.
Leave a comment