开发者

MSBuild extensionpack Copy all the contents of a Directory to another

I am using MSBuild extensionpack. I'd li开发者_运维百科ke to copy the entire contents of the build directory to another directory on the file system. I do not want to rename the destination directory, just replace the contents. It could be my unfamiliarity with msbuild extensionpack but it seems like this should be easy and I have been unable to find readily available documentation on the web.

I am trying to set up a service that is automatically deployed in the Continuous Integration environment after a successful build.


As far as I remember, you'll need to clear and copy in separate steps. So do the delete/purge first, then copy over. I wasn't able (at the time I last did) to find a way to "overwrite". This actually worked better for us b/c one build may remove files that a previous one contained, so we wouldn't want them to "linger".

To delete, try (assuming DeploymentDesintationPath is a property with the path):

<MSBuild.ExtensionPack.FileSystem.Folder
     TaskAction="RemoveContent" 
     path="$(DeploymentDestinationPath)" />

And then copy (notice you need to populate an itemgroup for both the source and the destination)

<ItemGroup>    
      <DeploymentSourceFiles
           Include="$(BuildFolder)\**\*"
      />  
      <DeploymentDestinationFiles
           Include="@(DeploymentSourceFiles->
           '$(DeploymentDestinationPath)\%(RecursiveDir)%(Filename)%(Extension)')"
      />  
</ItemGroup>

<Copy SourceFiles="@(DeploymentSourceFiles)"
     DestinationFiles="@(DeploymentDestinationFiles)" />

I haven't done this in a few months, so pardon if any of these examples require a bit of tweaking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜