我想知道如何使用MSBuild同步兩個文件夾,包括子文件夾。使用MSBUILD同步兩個文件夾
我喜歡做的是
一)從源文件夾中的所有文件複製到文件夾DEST是新 或DEST文件夾不存在
和
二)以去除 源文件夾中的不存在的(再在DEST文件夾中的所有文件)
a)是使用很容易任務但我該如何完成b)?
這是迄今爲止我的生成文件:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0"
DefaultTargets="Backup">
<PropertyGroup>
<SourceFolder>C:\source</SourceFolder>
<DestFolder>C:\dest</DestFolder>
</PropertyGroup>
<ItemGroup>
<FilesToCopy Include="$(SourceFolder)\**" />
</ItemGroup>
<Target Name="Backup">
<!-- copy all files from the source folder to the dest folder
that are newer or don't exist in the dest folder -->
<Copy
SourceFiles="@(FilesToCopy)"
DestinationFiles="@(FilesToCopy->'$(DestFolder)\%(RecursiveDir)%(Filename)%(Extension)')"
SkipUnchangedFiles="True" />
<!-- TODO: remove all files from the dest folder
that don't exist in the source folder -->
</Target>
</Project>
行之有效!我安裝了MSBuild-Extensions,並在構建文件中添加了 ' –
miasbeck